3133 lines
137 KiB
PHP
3133 lines
137 KiB
PHP
|
|
<?php
|
|||
|
|
/*error_reporting(E_ALL);
|
|||
|
|
ini_set('display_errors', 1);
|
|||
|
|
register_shutdown_function(function() {
|
|||
|
|
$error = error_get_last();
|
|||
|
|
if ($error && ($error['type'] === E_ERROR || $error['type'] === E_PARSE)) {
|
|||
|
|
echo "\n<!-- FATAL ERROR: " . $error['message'] . " in " . $error['file'] . " on line " . $error['line'] . " -->";
|
|||
|
|
}
|
|||
|
|
});*/
|
|||
|
|
require_once($_SERVER['DOCUMENT_ROOT'] . "/config.php");
|
|||
|
|
set_time_limit(0);
|
|||
|
|
ini_set('memory_limit', '8192M');
|
|||
|
|
|
|||
|
|
/*if(isset($_POST['dev'])){
|
|||
|
|
ini_set('display_errors', 1);
|
|||
|
|
error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE);
|
|||
|
|
}*/
|
|||
|
|
|
|||
|
|
$start = microtime(true);
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
if ($_SESSION['id']) {
|
|||
|
|
$get = clearInputData($_GET);
|
|||
|
|
$post = clearInputData($_POST);
|
|||
|
|
|
|||
|
|
// Определяем: запрос пришёл со страницы поиска (sale.php / main.php / new-main.php)
|
|||
|
|
$refererPath = isset($_SERVER['HTTP_REFERER']) ? parse_url($_SERVER['HTTP_REFERER'], PHP_URL_PATH) : '';
|
|||
|
|
$searchPages = ['/sale.php', '/main.php', '/new-main.php'];
|
|||
|
|
if (in_array($refererPath, $searchPages)) {
|
|||
|
|
$isSearch = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$gmtmsk = get_time_zone_user();
|
|||
|
|
|
|||
|
|
|
|||
|
|
$time_zone = '';
|
|||
|
|
|
|||
|
|
if($gmtmsk >= 0){
|
|||
|
|
$time_zone = '+'.$gmtmsk.' hour';
|
|||
|
|
} else {
|
|||
|
|
$time_zone = '-'.$gmtmsk.' hour';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($post['view'] !== 'table') {
|
|||
|
|
$_SESSION['list_view'] = 1;
|
|||
|
|
unset($_SESSION['table_view']);
|
|||
|
|
} else {
|
|||
|
|
$_SESSION['table_view'] = 1;
|
|||
|
|
unset($_SESSION['list_view']);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$_SESSION['myObjectsView'] = 1;
|
|||
|
|
unset($_SESSION['agencyObjectsView']);
|
|||
|
|
|
|||
|
|
$db_sphinx = new MysqlPdo(hstsph2, null, null, null, true, '9306');
|
|||
|
|
|
|||
|
|
if (isset($post['id_agent']) && $post['id_agent']) {
|
|||
|
|
$user_view = new User;
|
|||
|
|
$user_view->get($post['id_agent']);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$currentUser = new User;
|
|||
|
|
$currentUser->get($_SESSION['id']);
|
|||
|
|
|
|||
|
|
if (!isset($currentUser->agencyId)) {
|
|||
|
|
$currentUser->agencyId = $_SESSION['id'];
|
|||
|
|
$currentUser->agencyName = $currentUser->agency_name;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
//архив типов договоров
|
|||
|
|
$contract = new Contract();
|
|||
|
|
$contract->setAgencyId($currentUser->agencyId);
|
|||
|
|
$typesContracs = $contract->getTypesName();
|
|||
|
|
|
|||
|
|
|
|||
|
|
$db = new MysqlPdo(hstsph, null, null, null, true, '9306');
|
|||
|
|
|
|||
|
|
$showAvitoSwitcher = false;
|
|||
|
|
$showCianSwitcher = false;
|
|||
|
|
$showEmslSwitcher = false;
|
|||
|
|
$showBnSwitcher = false;
|
|||
|
|
$showZipalSwitcher = true;
|
|||
|
|
$showYandexSwitcher = true;
|
|||
|
|
$showDomSwitcher = true;
|
|||
|
|
|
|||
|
|
$sqlForAvitoSwitcher = "SELECT id FROM `users` WHERE id in (8771, 8681, 8702, 8669, 8519, 8499, 8524, 8271, 7945, 8410, 8307, 8222, 8317, 8259, 7929, 8133, 7846, 8128, 8080, 7941, 7927, 7949, 7920, 7933, 7730, 7861, 7811, 7828, 7811, 1543, 7705, 5274, 7605, 7598, 6755, 7441, 7225, 7322, 7325, 7321, 7161, 7255, 7254, 7253, 7252, 7251, 7249, 7289, 7248, 7245, 6531, 6841, 7156, 7102, 7078, 6998, 7142, 5530, 6995, 6793, 6935, 6916, 6876, 6917, 6858, 5427, 4, 93, 117, 4255, 4355, 920, 4826, 4112, 5598, 5766, 6007, 6358, 6370, 6730, 177, 6781, 6782) or id_manager in (8271, 7945, 8410, 8307, 8222, 8259, 7929, 8133, 7846, 8080, 7941, 7927, 7920, 7861, 7811, 7828, 7811, 7705, 5274, 7441, 5598, 93, 6858, 5530, 7248) or id_manager in (select id from users where id_manager in (8271, 7945, 8410, 8307, 8222, 8259, 7929, 8133, 7846, 8080, 7941, 7927, 7920, 7861, 7811, 7828, 7811, 7705, 5274, 7441, 5598, 93, 6858, 5530, 7248))";
|
|||
|
|
$rezForAvitoSwitcher = mysql_query($sqlForAvitoSwitcher);
|
|||
|
|
while($userId = mysql_fetch_assoc($rezForAvitoSwitcher)) {
|
|||
|
|
if ($userId['id'] == $_SESSION['id']) {
|
|||
|
|
$showAvitoSwitcher = true;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$sqlForCianSwitcher = "SELECT id FROM `users` WHERE id in (8771, 8681, 8702, 8669, 8519, 8499, 8524, 8271, 8410, 7507, 8307, 8285, 8222, 8317, 8259, 7929, 8133, 7846, 8128, 8080, 7941, 7927, 7949, 7920, 7933, 7730, 7861, 7811, 7828, 7811, 1543, 7705, 5274, 7605, 7598, 6755, 7441, 7225, 7325, 7321, 7161, 7255, 7254, 7253, 7252, 7251, 7249, 4101, 7248, 7245, 6531, 6841, 7156, 7102, 7078, 7142, 5530, 4, 93, 117) or id_manager in (8271, 8410, 7507, 8307, 8285, 8222, 8259, 7929, 8133, 7846, 8080, 7941, 7927, 7920, 7861, 7811, 7828, 7811, 7705, 5274, 7441, 5530, 7248) or id_manager in (select id from users where id_manager in (8271, 8410, 7507, 8307, 8285, 8222, 8259, 7929, 8133, 7846, 8080, 7941, 7927, 7920, 7861, 7811, 7828, 7811, 7705, 5274, 7441, 5530, 7248))";
|
|||
|
|
$rezForCianSwitcher = mysql_query($sqlForCianSwitcher);
|
|||
|
|
while($userId = mysql_fetch_assoc($rezForCianSwitcher)) {
|
|||
|
|
if ($userId['id'] == $_SESSION['id']) {
|
|||
|
|
$showCianSwitcher = true;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$sqlForEmslSwitcher = "SELECT id FROM `users` WHERE id in (8771, 8681, 8702, 8669, 8519, 8499, 8524, 8271, 7945, 8410, 8307, 8222, 8317, 8259, 7929, 8133, 7846, 8128, 8080, 7941, 7927, 7949, 7920, 7933, 7730, 7861, 7811, 7828, 7811, 1543, 7705, 5274, 7605, 7598, 5530, 6755, 7441, 7225, 7325, 7321, 7161, 7255, 7254, 7253, 7252, 7251, 7249, 7248, 7245, 6531, 6841, 6747, 7156, 7102, 7078, 7142, 6793, 6935, 6916, 6876, 6917, 6858, 5427, 4, 93, 117, 4255, 4355, 920, 4826, 4112, 5598, 5766, 6007, 6358, 6370, 6730, 177, 6781, 6782, 6842, 5238) or id_manager in (8271, 7945, 8410, 8307, 8222, 8259, 7929, 8133, 7846, 8080, 7941, 7927, 7920, 7861, 7811, 7828, 7811, 7705, 5274, 7441, 5598, 93, 6358, 6858, 7248) or id_manager in (select id from users where id_manager in (8271, 7945, 8410, 8307, 8222, 8259, 7929, 8133, 7846, 8080, 7941, 7927, 7920, 7861, 7811, 7828, 7811, 7705, 5274, 7441, 5598, 93, 6358, 6858, 7248))";
|
|||
|
|
$rezForEmslSwitcher = mysql_query($sqlForEmslSwitcher);
|
|||
|
|
while($userId = mysql_fetch_assoc($rezForEmslSwitcher)) {
|
|||
|
|
if ($userId['id'] == $_SESSION['id']) {
|
|||
|
|
$showEmslSwitcher = true;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$sqlForBnSwitcher = "SELECT id FROM `users` WHERE id in (8771, 8681, 8702, 8669, 8519, 8499, 8524, 8271, 8410, 8307, 8285, 8222, 8317, 8259, 7929, 8133, 7846, 8128, 8080, 7941, 7927, 7949, 7920, 7933, 7730, 7861, 7811, 7828, 7811, 1543, 7705, 5274, 7605, 7598, 5530, 6755, 7441, 7225, 7325, 7321, 7161, 7255, 7254, 7253, 7252, 7251, 7249, 7248, 7245, 6531, 6841, 7156, 7102, 7078, 7142, 6995, 6793, 6935, 6916, 6876, 6917, 6858, 5427, 4, 93, 117, 4255, 4355, 920, 4826, 4112, 5598, 5766, 6007, 6358, 6370, 6730, 177, 6781, 6782) or id_manager in (8271, 8410, 8307, 8285, 8222, 8259, 7929, 8133, 7846, 8080, 7941, 7927, 7920, 7861, 7811, 7828, 7811, 7705, 5274, 7441, 5598, 93, 6858, 7248) or id_manager in (select id from users where id_manager in (8271, 8410, 8307, 8285, 8222, 8259, 7929, 8133, 7846, 8080, 7941, 7927, 7920, 7861, 7811, 7828, 7811, 7705, 5274, 7441, 5598, 93, 6858, 7248))";
|
|||
|
|
$rezForBnSwitcher = mysql_query($sqlForBnSwitcher);
|
|||
|
|
while($userId = mysql_fetch_assoc($rezForBnSwitcher)) {
|
|||
|
|
if ($userId['id'] == $_SESSION['id']) {
|
|||
|
|
$showBnSwitcher = true;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$sqlForHideZipalSwitcher = "SELECT id FROM `users` WHERE id in (7226, 920, 4135) or id_manager in (7864, 920, 6543, 4135, 7507) or id_manager in (select id from users where id_manager in (7864, 920, 585, 6543, 4135, 7507))";
|
|||
|
|
$rezForHideZipalSwitcher = mysql_query($sqlForHideZipalSwitcher);
|
|||
|
|
while($userId = mysql_fetch_assoc($rezForHideZipalSwitcher)) {
|
|||
|
|
if ($userId['id'] == $_SESSION['id']) {
|
|||
|
|
$showZipalSwitcher = false;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($_SESSION['id'] == 6574 || $_SESSION['id'] == 6551 || $_SESSION['id'] == 6551 || $_SESSION['id'] == 6545 || $_SESSION['id'] == 7142 || $_SESSION['id'] == 5238) {
|
|||
|
|
$showZipalSwitcher = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$sqlForHideYandexSwitcher = "SELECT id FROM `users` WHERE id in (7226, 4135) or id_manager in (7864, 6007, 4135) or id_manager in (select id from users where id_manager in (7864, 6007, 4135))";
|
|||
|
|
$rezForHideYandexSwitcher = mysql_query($sqlForHideYandexSwitcher);
|
|||
|
|
while($userId = mysql_fetch_assoc($rezForHideYandexSwitcher)) {
|
|||
|
|
if ($userId['id'] == $_SESSION['id']) {
|
|||
|
|
$showYandexSwitcher = false;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($_SESSION['id'] == 7142) {
|
|||
|
|
$showYandexSwitcher = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$sqlForHideDomSwitcher = "SELECT id FROM `users` WHERE id in (7226, 4135) or id_manager in (7864, 6007, 4135) or id_manager in (select id from users where id_manager in (7864, 6007, 4135))";
|
|||
|
|
$resForHideDomSwitcher = mysql_query($sqlForHideDomSwitcher);
|
|||
|
|
while($userId = mysql_fetch_assoc($resForHideDomSwitcher)) {
|
|||
|
|
if ($userId['id'] == $_SESSION['id']) {
|
|||
|
|
$showDomSwitcher = false;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($_SESSION['id'] == 7142) {
|
|||
|
|
$showDomSwitcher = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($post['filter_ads_state_objects']) {
|
|||
|
|
$_SESSION['filter_ads_state_objects'] = $post['filter_ads_state_objects'];
|
|||
|
|
} else {
|
|||
|
|
unset($_SESSION['filter_ads_state_objects']);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$urlAdd = "sale=1&view=list";
|
|||
|
|
|
|||
|
|
if (isset($_GET['view'])) {
|
|||
|
|
$urlAdd = "sale=1&view=".$_GET['view'];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$depClass = new Department();
|
|||
|
|
$adminDep = false;
|
|||
|
|
$searchUserId = $_SESSION['id'];
|
|||
|
|
|
|||
|
|
$sql_check_permissions = "SELECT `menu_all_objects`, `menu_all_objects_edit` FROM user_permissions WHERE user_id = $searchUserId";
|
|||
|
|
$q_check_permissions = mysql_query($sql_check_permissions);
|
|||
|
|
$r_check_permissions = mysql_fetch_assoc($q_check_permissions);
|
|||
|
|
|
|||
|
|
if (!isset($user_view) && ($_SESSION['agency'] || $_SESSION['manager'] || $_SESSION['users_admin'] || $r_check_permissions['menu_all_objects'] == 1)) {
|
|||
|
|
$agentIds = [];
|
|||
|
|
if ($_SESSION['users_admin'] || $_SESSION['agency'] || $r_check_permissions['menu_all_objects'] == 1) {
|
|||
|
|
$user = new User;
|
|||
|
|
$user->checkPermissions();
|
|||
|
|
$searchUserId = $user->agencyId;
|
|||
|
|
$agentIds[] = $user->agencyId;
|
|||
|
|
} else {
|
|||
|
|
$user = new User;
|
|||
|
|
$user->get((int)$_SESSION['id']);
|
|||
|
|
$dep_user = $depClass->getDepartment((int)$_SESSION['id']);
|
|||
|
|
if ($dep_user['role'] == 'manager_office') {
|
|||
|
|
$searchUserId = $dep_user['admin'];
|
|||
|
|
$adminDep = true;
|
|||
|
|
} else if ($dep_user['role'] == 'manager_office_menager') {
|
|||
|
|
$searchUserId = $user->id_manager;
|
|||
|
|
$adminDep = true;
|
|||
|
|
} else if($dep_user['role'] == 'admin_department'){
|
|||
|
|
$adminDep = true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
$agentIds[] = $searchUserId;
|
|||
|
|
$agentsOfAgency = User::getAllAgents($searchUserId);
|
|||
|
|
foreach ($agentsOfAgency as $agent) {
|
|||
|
|
if (!in_array($agent['id'], $agentIds)) {
|
|||
|
|
$agentIds[] = $agent['id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($_SESSION['agency'] || $_SESSION['users_admin'] || $r_check_permissions['menu_all_objects'] == 1) {
|
|||
|
|
$sc = new SourcesConnection($user->agencyId);
|
|||
|
|
$agentIds = $sc->getAllUserAgency();
|
|||
|
|
} else if ($adminDep) {
|
|||
|
|
$agentsOfManager = User::getAllManagers($searchUserId);
|
|||
|
|
foreach ($agentsOfManager as $agent) {
|
|||
|
|
if (!in_array($agent['id'], $agentIds)) {
|
|||
|
|
$agentIds[] = $agent['id'];
|
|||
|
|
}
|
|||
|
|
if((int)$agent['role_id'] > 0 && (int)$agent['department_id'] > 0){
|
|||
|
|
$role_user = $depClass->getRole((int)$agent['role_id']);
|
|||
|
|
if($role_user['role'] == 'admin_department'){
|
|||
|
|
$menagerDep = User::getDepManagers($role_user['department_id']);
|
|||
|
|
foreach($menagerDep as $md){
|
|||
|
|
if(!in_array($md['id'], $agentIds)){
|
|||
|
|
$agentIds[] = $md['id'];
|
|||
|
|
|
|||
|
|
$thisAgents = User::getAgentsOfAgency($md['id'], true);
|
|||
|
|
|
|||
|
|
foreach($thisAgents as $da){
|
|||
|
|
if (!in_array($da['id'], $agentIds)) {
|
|||
|
|
$agentIds[] = $da['id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
$agentIds = isset($user_view) ? [$user_view->id] : [$searchUserId];
|
|||
|
|
$agentIds = array_merge($agentIds, $agentIds);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$favor = array();
|
|||
|
|
$favorUserView = array();
|
|||
|
|
$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) OR
|
|||
|
|
id_manager in (select us.id from users us where us.id_manager in (select usrs.id from users usrs where usrs.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;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
$agentIds = array_merge($agentIds, $empWho);
|
|||
|
|
if (!isset($user_view)) {
|
|||
|
|
|
|||
|
|
$sql_f = "SELECT id_obj FROM favor WHERE id_user IN (" . implode(',', $agentIds) . ")";
|
|||
|
|
if (!empty($empWho)){
|
|||
|
|
//$str_usl_bd .= " AND id_add_user IN (" . implode(", ", $empWho) . ")";
|
|||
|
|
$sql_f = "SELECT id_obj FROM favor WHERE id_user IN (" . implode(',', $empWho) . ")";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$q_f = mysql_query($sql_f);
|
|||
|
|
while($r_f = mysql_fetch_row($q_f)){
|
|||
|
|
$favor[] = $r_f[0];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(!empty($favor)){
|
|||
|
|
$sql = "SELECT count(*) FROM objects WHERE id in (".implode(',', $favor).")";
|
|||
|
|
|
|||
|
|
$rez = $db_sphinx->query($sql);
|
|||
|
|
|
|||
|
|
$kol_favor = $db_sphinx->result($rez);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
$objFav = array();
|
|||
|
|
|
|||
|
|
$sql_f = "SELECT id_obj FROM favor WHERE id_user IN (" . implode(',', $agentIds) . ")";
|
|||
|
|
if (!empty($empWho)){
|
|||
|
|
//$str_usl_bd .= " AND id_add_user IN (" . implode(", ", $empWho) . ")";
|
|||
|
|
$sql_f = "SELECT id_obj FROM favor WHERE id_user IN (" . implode(',', $empWho) . ")";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
$q_f = mysql_query($sql_f);
|
|||
|
|
while($r_f = mysql_fetch_row($q_f)){
|
|||
|
|
$objFav[] = $r_f[0];
|
|||
|
|
}
|
|||
|
|
if(!empty($objFav)){
|
|||
|
|
$sql = "SELECT id FROM objects WHERE id in (".implode(',', $objFav).") LIMIT 100000 OPTION max_matches=100000";
|
|||
|
|
$rez = $db_sphinx->query($sql);
|
|||
|
|
while ($f = $db_sphinx->fetch_assoc($rez)) $favorUserView[] = $f['id'];
|
|||
|
|
}
|
|||
|
|
if ($favorUserView) {
|
|||
|
|
$kol_favor = count($favorUserView);
|
|||
|
|
}
|
|||
|
|
if (isset($_GET['favor'])) {
|
|||
|
|
$favor = $favorUserView;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$user = new User;
|
|||
|
|
$user->get($searchUserId);
|
|||
|
|
$use_advert_budget = boolval($_SESSION['use_advert_budget']);
|
|||
|
|
|
|||
|
|
$needAd = false;
|
|||
|
|
$sqlForAd = "SELECT id FROM `users` WHERE id in (4, 93, 117, 4251, 5035, 585, 4147, 5350, 5355, 177, 5524, 5530, 5839) or id_manager in (4, 117, 4251, 5035, 585, 4147, 5350, 5355, 177, 5524, 5530, 5839) or id_manager in (select id from users where id_manager in (4, 117, 4251, 5035, 585, 4147, 5350, 5355, 177, 5524, 5530, 5839))";
|
|||
|
|
$rezForAd = mysql_query($sqlForAd);
|
|||
|
|
while($userId=mysql_fetch_assoc($rezForAd)) {
|
|||
|
|
if ($userId['id'] == $_SESSION['id']) {
|
|||
|
|
$needAd = true;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$isPotential = ($post['selected'] == 'potential');
|
|||
|
|
$isArchive = ($post['selected'] == 'archive');
|
|||
|
|
$isFavor = ($post['selected'] == 'favor');
|
|||
|
|
|
|||
|
|
list ($mas_usl_bd, $mas_url_add, $order) = search($post, false, $favor, true);
|
|||
|
|
|
|||
|
|
$order = " ORDER BY date_add DESC ";
|
|||
|
|
$orderSql = " ORDER BY objects.date_add DESC ";
|
|||
|
|
$sortOrder = (isset($_POST['sort_order'])) ? $_POST['sort_order'] : null;
|
|||
|
|
|
|||
|
|
if ($sortOrder == null && isset($_SESSION['my_objects_sort_order']))
|
|||
|
|
$sortOrder = $_SESSION['my_objects_sort_order'];
|
|||
|
|
|
|||
|
|
if (!isset($_SESSION['my_objects_sort_order'])) {
|
|||
|
|
$sortOrder = 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$additional_join = '';
|
|||
|
|
$additional_select = '';
|
|||
|
|
|
|||
|
|
if (isset($sortOrder)) {
|
|||
|
|
$_SESSION['my_objects_sort_order'] = $sortOrder;
|
|||
|
|
switch (intval($sortOrder)) {
|
|||
|
|
case 0:
|
|||
|
|
$order = ' ORDER BY date_add DESC ';
|
|||
|
|
$orderSql = ' ORDER BY objects.date_add DESC ';
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
case 1:
|
|||
|
|
$order = ' ORDER BY date_add ASC ';
|
|||
|
|
$orderSql = ' ORDER BY objects.date_add ASC ';
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
case 2:
|
|||
|
|
$order = ' ORDER BY date_really_add DESC ';
|
|||
|
|
$orderSql = ' ORDER BY objects.date_really_add DESC ';
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
case 3:
|
|||
|
|
$order = ' ORDER BY date_really_add ASC ';
|
|||
|
|
$orderSql = ' ORDER BY objects.date_really_add ASC ';
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
case 4:
|
|||
|
|
$additional_join = 'LEFT JOIN object_prices ON object_prices.object_id = objects.id';
|
|||
|
|
$additional_select = 'object_prices.currency, object_prices.price_avito, IF (object_prices.currency > 0, object_prices.price_avito, objects.stoim) AS sort_price,';
|
|||
|
|
$order = ' ORDER BY sort_price ASC ';
|
|||
|
|
$orderSql = ' ORDER BY sort_price ASC ';
|
|||
|
|
break;
|
|||
|
|
|
|||
|
|
case 5:
|
|||
|
|
$additional_join = 'LEFT JOIN object_prices ON object_prices.object_id = objects.id';
|
|||
|
|
$additional_select = 'object_prices.currency, object_prices.price_avito, IF (object_prices.currency > 0, object_prices.price_avito, objects.stoim) AS sort_price,';
|
|||
|
|
$order = ' ORDER BY sort_price DESC ';
|
|||
|
|
$orderSql = ' ORDER BY sort_price DESC ';
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($mas_usl_bd) {
|
|||
|
|
$str_usl_bd = implode(" AND ", $mas_usl_bd);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($post['selected'] == 'archive') {
|
|||
|
|
$str_usl_bd .= " AND archive = 1 AND id_add_user IN (" . implode(',', $agentIds) . ")";
|
|||
|
|
} else {
|
|||
|
|
if ($post['selected'] == 'potential') {
|
|||
|
|
$sql_u_p = "SELECT distinct object_id from user_potential_objects where user_id IN (" . implode(',', $agentIds) . ")";
|
|||
|
|
$q_u_p = mysql_query($sql_u_p);
|
|||
|
|
$agentIdsUP = array();
|
|||
|
|
while($r_u_p = mysql_fetch_row($q_u_p)){
|
|||
|
|
$agentIdsUP[] = $r_u_p[0];
|
|||
|
|
}
|
|||
|
|
if(!empty($agentIdsUP)){
|
|||
|
|
$str_usl_bd .= " AND id in (" . implode(',', $agentIdsUP) . ")";
|
|||
|
|
} else {
|
|||
|
|
$str_usl_bd .= " AND id = 0";
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
if ($post['selected'] == 'favor') {
|
|||
|
|
|
|||
|
|
if(!empty($favor)){
|
|||
|
|
$str_usl_bd .= " AND id in (" . implode(',', $favor) . ")";
|
|||
|
|
} else {
|
|||
|
|
$str_usl_bd .= " AND id = 0";
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
if ($post['selected'] == 'ad') {
|
|||
|
|
$str_usl_bd .= " AND use_in_advert = 1 AND id_add_user IN (" . implode(',', $agentIds) . ")";
|
|||
|
|
} else {
|
|||
|
|
$str_usl_bd .= " AND archive <> 1 AND id_add_user IN (" . implode(',', $agentIds) . ")";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Фильтрация по доп. полям
|
|||
|
|
if (isset($_SESSION['filter_object_fields']['sql'])) {
|
|||
|
|
if($post['dev']){
|
|||
|
|
var_dump($_SESSION['filter_object_fields']['sql']);
|
|||
|
|
}
|
|||
|
|
$fields_filter = $_SESSION['filter_object_fields']['sql'];
|
|||
|
|
if (count($fields_filter)) {
|
|||
|
|
|
|||
|
|
$obj_ids = [];
|
|||
|
|
foreach ($fields_filter as $sql) {
|
|||
|
|
$sql = "SELECT `object_id` FROM `object_data` WHERE $sql";
|
|||
|
|
$query = mysql_query($sql);
|
|||
|
|
|
|||
|
|
$result = [];
|
|||
|
|
while($row = mysql_fetch_row($query)) {
|
|||
|
|
$result[] = $row[0];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!empty($obj_ids))
|
|||
|
|
$obj_ids = array_intersect($obj_ids, $result);
|
|||
|
|
else
|
|||
|
|
$obj_ids = $result;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$obj_ids = array_unique($obj_ids);
|
|||
|
|
|
|||
|
|
if (count($obj_ids))
|
|||
|
|
$str_usl_bd .= ' AND id IN ('.implode(',', $obj_ids).') ';
|
|||
|
|
else
|
|||
|
|
$str_usl_bd .= ' AND id < 0 '; // искусственно ограничиваем выборку, поскольку нет совпадений с кастомными полями
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//фильтрация по договорам
|
|||
|
|
if(isset($post['is_contract']) && $post['is_contract']=='true'){
|
|||
|
|
|
|||
|
|
$part_where = "SELECT object_id FROM contracts_object WHERE agency_id = {$currentUser->agencyId}";
|
|||
|
|
|
|||
|
|
if(isset($post['numder_contract']) && !empty($post['numder_contract'])){
|
|||
|
|
$part_where .= " AND number like '%{$post['numder_contract']}%'";
|
|||
|
|
}
|
|||
|
|
if(isset($post['type_contract']) && !empty($post['type_contract'])){
|
|||
|
|
$part_where .= " AND type in (".implode(',',$post['type_contract']).")";
|
|||
|
|
}
|
|||
|
|
if(isset($post['onDateContract']) && $post['onDateContract'] > 0){
|
|||
|
|
$date_on = strtotime($post['onDateContract']." 00:00:00");
|
|||
|
|
$part_where .= " AND date_end >= $date_on";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(isset($post['offDateContract']) && $post['offDateContract'] > 0){
|
|||
|
|
$date_off = strtotime($post['offDateContract']." 23:59:59");
|
|||
|
|
$part_where .= " AND date_end <= $date_off";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$obj_ids = [];
|
|||
|
|
|
|||
|
|
$query_fields = mysql_query($part_where);
|
|||
|
|
while($row = mysql_fetch_row($query_fields)) {
|
|||
|
|
$obj_ids[] = $row[0];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (count($obj_ids))
|
|||
|
|
$str_usl_bd .= ' AND id IN ('.implode(',', $obj_ids).') ';
|
|||
|
|
else
|
|||
|
|
$str_usl_bd .= ' AND id < 0 '; // искусственно ограничиваем выборку, поскольку нет совпадений с кастомными полями
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$addToAvitoFilter = (int) $_POST['addToAvitoFilter'];
|
|||
|
|
$addToCianFilter = (int) $_POST['addToCianFilter'];
|
|||
|
|
$addToDomClickFilter = (int) $_POST['addToDomClickFilter'];
|
|||
|
|
$addToEMLSFilter = (int) $_POST['addToEMLSFilter'];
|
|||
|
|
$addToYandexFilter = (int) $_POST['addToYandexFilter'];
|
|||
|
|
|
|||
|
|
if ($post['not_advert'] > 0 && $addToAvitoFilter <= 0 && $addToCianFilter <= 0 && $addToDomClickFilter <= 0 && $addToYandexFilter <= 0) {
|
|||
|
|
$str_usl_bd .= " AND archive <> 1 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_add_user IN (" . implode(',', $agentIds) . ") ";
|
|||
|
|
$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)) {
|
|||
|
|
$str_usl_bd .= ' AND id NOT IN (' . implode(',', $arr_pac) . ') ';
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($post['not_advert'] > 0 && ($addToAvitoFilter > 0 || $addToCianFilter > 0 || $addToDomClickFilter > 0 || $addToYandexFilter > 0)) {
|
|||
|
|
|
|||
|
|
if ($addToAvitoFilter > 0) {
|
|||
|
|
$str_usl_bd .= ' AND add_to_avito_feed=0 ';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($addToCianFilter > 0) {
|
|||
|
|
$str_usl_bd .= ' AND add_to_cian_feed=0 ';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($addToDomClickFilter > 0) {
|
|||
|
|
$str_usl_bd .= ' AND add_to_domclick_feed=0 ';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($addToYandexFilter > 0) {
|
|||
|
|
$str_usl_bd .= ' AND add_to_bn_feed=0 ';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$str_usl_bd .= " AND id_add_user IN (" . implode(',', $agentIds) . ") ";
|
|||
|
|
|
|||
|
|
$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)) {
|
|||
|
|
$str_usl_bd .= ' AND id NOT IN (' . implode(',', $arr_pac) . ') ';
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($post['filter_employee'] && $post['selected'] != 'favor') {
|
|||
|
|
$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)){
|
|||
|
|
|
|||
|
|
$str_usl_bd .= " AND id_add_user IN (" . implode(", ", $empWho) . ")";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$_SESSION['filter_emp'] = $post['filter_employee'];
|
|||
|
|
} else {
|
|||
|
|
unset($_SESSION['filter_emp']);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
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))
|
|||
|
|
$str_usl_bd .= " AND type IN (" . implode(',', $ob_types) . ")";
|
|||
|
|
|
|||
|
|
$_SESSION['filter_object_type'] = $post['filter_type'];
|
|||
|
|
} else {
|
|||
|
|
unset($_SESSION['filter_object_type']);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!empty($post['filter_activities'])) {
|
|||
|
|
$activitiesArr = json_decode(html_entity_decode($post['filter_activities']), ENT_QUOTES);
|
|||
|
|
|
|||
|
|
$noTagsKey = array_search('no_tags', $activitiesArr);
|
|||
|
|
$hasNoTags = ($noTagsKey !== false);
|
|||
|
|
|
|||
|
|
if ($hasNoTags) {
|
|||
|
|
unset($activitiesArr[$noTagsKey]);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($hasNoTags && !empty($activitiesArr)) {
|
|||
|
|
// Получаем ID объектов с выбранными тегами из MySQL
|
|||
|
|
$objWithTags = 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_array($q_a)){
|
|||
|
|
$objWithTags[] = $r_a[0];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$base_conditions = preg_replace('/^\s*AND\s+/i', '', $str_usl_bd);
|
|||
|
|
$sql_no_tags_ids = "SELECT id FROM objects WHERE $base_conditions AND has_activities = 0 LIMIT 10000 OPTION max_matches=10000";
|
|||
|
|
$result_no_tags = $db_sphinx->query($sql_no_tags_ids, true);
|
|||
|
|
$ids_no_tags = array();
|
|||
|
|
while ($row = $db_sphinx->fetch_assoc($result_no_tags)) {
|
|||
|
|
$ids_no_tags[] = $row['id'];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Объединяем объекты без тегов и объекты с выбранными тегами
|
|||
|
|
$allIds = array_merge($ids_no_tags, $objWithTags);
|
|||
|
|
$allIds = array_unique($allIds);
|
|||
|
|
|
|||
|
|
if (!empty($allIds)) {
|
|||
|
|
$str_usl_bd .= " AND id IN (" . implode(", ", $allIds) . ")";
|
|||
|
|
} else {
|
|||
|
|
$str_usl_bd .= " AND id IN (0)";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
} elseif ($hasNoTags) {
|
|||
|
|
// Только "Без тегов"
|
|||
|
|
$str_usl_bd .= " AND has_activities = 0";
|
|||
|
|
} elseif (!empty($activitiesArr)) {
|
|||
|
|
// Только обычные теги (оригинальная логика)
|
|||
|
|
$objWithTags = 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_array($q_a)){
|
|||
|
|
$objWithTags[] = $r_a[0];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!empty($objWithTags)) {
|
|||
|
|
$str_usl_bd .= " AND id IN (" . implode(", ", $objWithTags) . ")";
|
|||
|
|
} else {
|
|||
|
|
$str_usl_bd .= " AND id IN (0)";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$_SESSION['filter_activities'] = $post['filter_activities'];
|
|||
|
|
} else {
|
|||
|
|
unset($_SESSION['filter_activities']);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (isset($post['object_commission']) && $post['object_commission']) {
|
|||
|
|
$str_usl_bd .= " AND commission >= " . $post['object_commission'];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (isset($post['object_commission_to']) && $post['object_commission_to']) {
|
|||
|
|
$str_usl_bd .= " AND commission <= " . $post['object_commission_to'];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (isset($post['object_cena_ot']) && $post['object_cena_ot']) {
|
|||
|
|
$str_usl_bd .= " AND price_for_order >= " . $post['object_cena_ot'];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (isset($post['object_cena_do']) && $post['object_cena_do']) {
|
|||
|
|
$str_usl_bd .= " AND price_for_order <= " . $post['object_cena_do'];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$str_usl_dealType = '';
|
|||
|
|
|
|||
|
|
if (isset($post['dealTypes']) && $post['dealTypes']) {
|
|||
|
|
$dealTypeArr = json_decode(html_entity_decode($post['dealTypes']), ENT_QUOTES);
|
|||
|
|
|
|||
|
|
if(!empty($dealTypeArr)){
|
|||
|
|
$str_usl_dealType .= " AND deal_type IN (" . implode(", ", $dealTypeArr) . ")";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (isset($post['object_komnat_from']) && $post['object_komnat_from']) {
|
|||
|
|
$str_usl_bd .= " AND komnat >= " . $post['object_komnat_from'];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (isset($post['object_komnat_to']) && $post['object_komnat_to']) {
|
|||
|
|
$str_usl_bd .= " AND komnat <= " . $post['object_komnat_to'];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$sqlZipalErr = "SELECT object_id, error_text, sended, published FROM zipal_objects WHERE error_text IS NOT NULL";
|
|||
|
|
$zipalErrResult = mysql_query($sqlZipalErr);
|
|||
|
|
|
|||
|
|
$zipalObjectsWithError = array();
|
|||
|
|
while ($res = mysql_fetch_array($zipalErrResult)) {
|
|||
|
|
$zipalObjectsWithError[] = $res;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
$s_3 = '';
|
|||
|
|
$arrayFids = array();
|
|||
|
|
|
|||
|
|
if ($post['ads_errors'] <= 0 && $post['ads_sended'] <= 0 && $post['ads_good_adv'] <= 0 && $post['not_advert'] <= 0 && $post['removed_publication'] <= 0) {
|
|||
|
|
// AND id_add_user IN (" . implode(',', $agentIds) . ")";
|
|||
|
|
if ($addToAvitoFilter > 0) {
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_avito_feed=1 AND id_add_user IN (" . implode(',', $agentIds) . ") LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arrayFids[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
if ($addToCianFilter > 0) {
|
|||
|
|
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_cian_feed=1 AND id_add_user IN (" . implode(',', $agentIds) . ") LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arrayFids[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($addToDomClickFilter > 0) {
|
|||
|
|
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_domclick_feed=1 AND id_add_user IN (" . implode(',', $agentIds) . ") LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arrayFids[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($addToEMLSFilter > 0) {
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_emls_feed=1 AND id_add_user IN (" . implode(',', $agentIds) . ") LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arrayFids[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($addToYandexFilter > 0) {
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_bn_feed=1 AND id_add_user IN (" . implode(',', $agentIds) . ") LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arrayFids[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$param7 = (int)$_POST['filter_is_package'];
|
|||
|
|
$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)) {
|
|||
|
|
$arrayFids[] = $r_pac[0];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$param3 = (int)$_POST['is_reports'];
|
|||
|
|
$s_4 = '';
|
|||
|
|
if ($param3 > 0) {
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_zipal=1 AND id_add_user IN (" . implode(',', $agentIds) . ") LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arrayFids[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
$param4 = (int)$_POST['is_free'];
|
|||
|
|
$s_5 = '';
|
|||
|
|
if ($param4 > 0) {
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_yandex_feed=1 AND id_add_user IN (" . implode(',', $agentIds) . ") LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arrayFids[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($post['ads_errors'] == '1' && $addToAvitoFilter <= 0 && $addToCianFilter <= 0 && $addToDomClickFilter <= 0 && $addToYandexFilter <= 0) {
|
|||
|
|
|
|||
|
|
$arr_obj = array();
|
|||
|
|
$s_local = '';
|
|||
|
|
|
|||
|
|
$sql_ads = "SELECT DISTINCT(`object_id`) FROM `ads_stats` WHERE `agency_id` = '$currentUser->agencyId' AND `errors` IS NOT NULL AND `service_id` = 1";
|
|||
|
|
$rezAdsErrors = mysql_query($sql_ads);
|
|||
|
|
if (mysql_num_rows($rezAdsErrors) > 0) {
|
|||
|
|
while ($objAdsInfo = mysql_fetch_assoc($rezAdsErrors)) {
|
|||
|
|
$arr_obj[] = $objAdsInfo['object_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!empty($arr_obj)) {
|
|||
|
|
$s_local .= ' AND id IN (' . implode(',', $arr_obj) . ') ';
|
|||
|
|
|
|||
|
|
//то, что размещено на авито и ошибка в ads_stats
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_avito_feed=1 AND id_add_user IN (" . implode(',', $agentIds) . ") $s_local LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arrayFids[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$arr_obj = array();
|
|||
|
|
$s_local = '';
|
|||
|
|
|
|||
|
|
$sql_ads = "SELECT DISTINCT(`object_id`) FROM `ads_stats` WHERE `agency_id` = '$currentUser->agencyId' AND `errors` IS NOT NULL AND `service_id` = 2";
|
|||
|
|
$rezAdsErrors = mysql_query($sql_ads);
|
|||
|
|
if (mysql_num_rows($rezAdsErrors) > 0) {
|
|||
|
|
while ($objAdsInfo = mysql_fetch_assoc($rezAdsErrors)) {
|
|||
|
|
$arr_obj[] = $objAdsInfo['object_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!empty($arr_obj)) {
|
|||
|
|
$s_local .= ' AND id IN (' . implode(',', $arr_obj) . ') ';
|
|||
|
|
|
|||
|
|
//то, что размещено на циан и ошибка в ads_stats
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_cian_feed=1 AND id_add_user IN (" . implode(',', $agentIds) . ") $s_local LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arrayFids[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$arr_obj = array();
|
|||
|
|
$s_local = '';
|
|||
|
|
|
|||
|
|
$sql_ads = "SELECT DISTINCT(`object_id`) FROM `ads_stats` WHERE `agency_id` = '$currentUser->agencyId' AND `errors` IS NOT NULL AND `service_id` = 4";
|
|||
|
|
$rezAdsErrors = mysql_query($sql_ads);
|
|||
|
|
if (mysql_num_rows($rezAdsErrors) > 0) {
|
|||
|
|
while ($objAdsInfo = mysql_fetch_assoc($rezAdsErrors)) {
|
|||
|
|
$arr_obj[] = $objAdsInfo['object_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!empty($arr_obj)) {
|
|||
|
|
$s_local .= ' AND id IN (' . implode(',', $arr_obj) . ') ';
|
|||
|
|
|
|||
|
|
//то, что размещено на домклик и ошибка в ads_stats
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_domclick_feed=1 AND id_add_user IN (" . implode(',', $agentIds) . ") $s_local LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arrayFids[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$arr_obj = array();
|
|||
|
|
$s_local = '';
|
|||
|
|
|
|||
|
|
$sql_ads = "SELECT DISTINCT(`object_id`) FROM `ads_stats` WHERE `agency_id` = '$currentUser->agencyId' AND `errors` IS NOT NULL AND `service_id` = 3";
|
|||
|
|
$rezAdsErrors = mysql_query($sql_ads);
|
|||
|
|
if (mysql_num_rows($rezAdsErrors) > 0) {
|
|||
|
|
while ($objAdsInfo = mysql_fetch_assoc($rezAdsErrors)) {
|
|||
|
|
$arr_obj[] = $objAdsInfo['object_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!empty($arr_obj)) {
|
|||
|
|
$s_local .= ' AND id IN (' . implode(',', $arr_obj) . ') ';
|
|||
|
|
|
|||
|
|
//то, что размещено на яндекс и ошибка в ads_stats
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_bn_feed=1 AND id_add_user IN (" . implode(',', $agentIds) . ") $s_local LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arrayFids[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// статус С ошибкой и выбрана площадка
|
|||
|
|
if ($post['ads_errors'] == '1' && ($addToAvitoFilter > 0 || $addToCianFilter > 0 || $addToDomClickFilter > 0 || $addToYandexFilter > 0)) {
|
|||
|
|
|
|||
|
|
if ($addToAvitoFilter > 0) {
|
|||
|
|
$arr_obj = array();
|
|||
|
|
$s_local = '';
|
|||
|
|
|
|||
|
|
$sql_ads = "SELECT DISTINCT(`object_id`) FROM `ads_stats` WHERE `agency_id` = '$currentUser->agencyId' AND `errors` IS NOT NULL AND `service_id` = 1";
|
|||
|
|
$rezAdsErrors = mysql_query($sql_ads);
|
|||
|
|
if (mysql_num_rows($rezAdsErrors) > 0) {
|
|||
|
|
while ($objAdsInfo = mysql_fetch_assoc($rezAdsErrors)) {
|
|||
|
|
$arr_obj[] = $objAdsInfo['object_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!empty($arr_obj)) {
|
|||
|
|
$s_local .= ' AND id IN (' . implode(',', $arr_obj) . ') ';
|
|||
|
|
|
|||
|
|
//то, что размещено на авито и ошибка в ads_stats
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_avito_feed=1 AND id_add_user IN (" . implode(',', $agentIds) . ") $s_local LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arrayFids[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if ($addToCianFilter > 0) {
|
|||
|
|
$arr_obj = array();
|
|||
|
|
$s_local = '';
|
|||
|
|
|
|||
|
|
$sql_ads = "SELECT DISTINCT(`object_id`) FROM `ads_stats` WHERE `agency_id` = '$currentUser->agencyId' AND `errors` IS NOT NULL AND `service_id` = 2";
|
|||
|
|
$rezAdsErrors = mysql_query($sql_ads);
|
|||
|
|
if (mysql_num_rows($rezAdsErrors) > 0) {
|
|||
|
|
while ($objAdsInfo = mysql_fetch_assoc($rezAdsErrors)) {
|
|||
|
|
$arr_obj[] = $objAdsInfo['object_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!empty($arr_obj)) {
|
|||
|
|
$s_local .= ' AND id IN (' . implode(',', $arr_obj) . ') ';
|
|||
|
|
|
|||
|
|
//то, что размещено на циан и ошибка в ads_stats
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_cian_feed=1 AND id_add_user IN (" . implode(',', $agentIds) . ") $s_local LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arrayFids[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if ($addToDomClickFilter > 0) {
|
|||
|
|
$arr_obj = array();
|
|||
|
|
$s_local = '';
|
|||
|
|
|
|||
|
|
$sql_ads = "SELECT DISTINCT(`object_id`) FROM `ads_stats` WHERE `agency_id` = '$currentUser->agencyId' AND `errors` IS NOT NULL AND `service_id` = 4";
|
|||
|
|
$rezAdsErrors = mysql_query($sql_ads);
|
|||
|
|
if (mysql_num_rows($rezAdsErrors) > 0) {
|
|||
|
|
while ($objAdsInfo = mysql_fetch_assoc($rezAdsErrors)) {
|
|||
|
|
$arr_obj[] = $objAdsInfo['object_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!empty($arr_obj)) {
|
|||
|
|
$s_local .= ' AND id IN (' . implode(',', $arr_obj) . ') ';
|
|||
|
|
|
|||
|
|
//то, что размещено на домклик и ошибка в ads_stats
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_domclick_feed=1 AND id_add_user IN (" . implode(',', $agentIds) . ") $s_local LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arrayFids[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if ($addToYandexFilter > 0) {
|
|||
|
|
$arr_obj = array();
|
|||
|
|
$s_local = '';
|
|||
|
|
|
|||
|
|
$sql_ads = "SELECT DISTINCT(`object_id`) FROM `ads_stats` WHERE `agency_id` = '$currentUser->agencyId' AND `errors` IS NOT NULL AND `service_id` = 3";
|
|||
|
|
$rezAdsErrors = mysql_query($sql_ads);
|
|||
|
|
if (mysql_num_rows($rezAdsErrors) > 0) {
|
|||
|
|
while ($objAdsInfo = mysql_fetch_assoc($rezAdsErrors)) {
|
|||
|
|
$arr_obj[] = $objAdsInfo['object_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!empty($arr_obj)) {
|
|||
|
|
$s_local .= ' AND id IN (' . implode(',', $arr_obj) . ') ';
|
|||
|
|
|
|||
|
|
//то, что размещено на яндекс и ошибка в ads_stats
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_bn_feed=1 AND id_add_user IN (" . implode(',', $agentIds) . ") $s_local LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arrayFids[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function getAllSendedAvito($db_sphinx, $user_view, $users_sp) {
|
|||
|
|
$arr_obj = array();
|
|||
|
|
$s_local = '';
|
|||
|
|
$arrayLocal = array();
|
|||
|
|
|
|||
|
|
$sql_ads = "SELECT DISTINCT(`object_id`) FROM `ads_stats` WHERE `agency_id` = '$user_view->agencyId' AND `service_id` = 1";
|
|||
|
|
$rezAdsErrors = mysql_query($sql_ads);
|
|||
|
|
if (mysql_num_rows($rezAdsErrors) > 0) {
|
|||
|
|
while ($objAdsInfo = mysql_fetch_assoc($rezAdsErrors)) {
|
|||
|
|
$arr_obj[] = $objAdsInfo['object_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!empty($arr_obj)) {
|
|||
|
|
$s_local .= ' AND id NOT IN (' . implode(',', $arr_obj) . ') ';
|
|||
|
|
} else {
|
|||
|
|
$s_local .= '';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//то, что размещено на авито и не появилось в ads_stats
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_avito_feed=1 AND id_add_user IN (" . implode(',', $users_sp) . ") $s_local LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arrayLocal[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return array_unique($arrayLocal);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function getAllSendedCian($db_sphinx, $user_view, $users_sp) {
|
|||
|
|
$arr_obj = array();
|
|||
|
|
$s_local = '';
|
|||
|
|
$arrayLocal = array();
|
|||
|
|
|
|||
|
|
$sql_ads = "SELECT DISTINCT(`object_id`) FROM `ads_stats` WHERE `agency_id` = '$user_view->agencyId' AND `service_id` = 2";
|
|||
|
|
$rezAdsErrors = mysql_query($sql_ads);
|
|||
|
|
if (mysql_num_rows($rezAdsErrors) > 0) {
|
|||
|
|
while ($objAdsInfo = mysql_fetch_assoc($rezAdsErrors)) {
|
|||
|
|
$arr_obj[] = $objAdsInfo['object_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!empty($arr_obj)) {
|
|||
|
|
$s_local .= ' AND id NOT IN (' . implode(',', $arr_obj) . ') ';
|
|||
|
|
} else {
|
|||
|
|
$s_local .= '';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//то, что размещено на циан и не появилось в ads_stats
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_cian_feed=1 AND id_add_user IN (" . implode(',', $users_sp) . ") $s_local LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arrayLocal[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return array_unique($arrayLocal);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function getAllSendedDom($db_sphinx, $user_view, $users_sp) {
|
|||
|
|
$arr_obj = array();
|
|||
|
|
$s_local = '';
|
|||
|
|
$arrayLocal = array();
|
|||
|
|
|
|||
|
|
$sql_ads = "SELECT DISTINCT(`object_id`) FROM `ads_stats` WHERE `agency_id` = '$user_view->agencyId' AND `service_id` = 4";
|
|||
|
|
$rezAdsErrors = mysql_query($sql_ads);
|
|||
|
|
if (mysql_num_rows($rezAdsErrors) > 0) {
|
|||
|
|
while ($objAdsInfo = mysql_fetch_assoc($rezAdsErrors)) {
|
|||
|
|
$arr_obj[] = $objAdsInfo['object_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!empty($arr_obj)) {
|
|||
|
|
$s_local .= ' AND id NOT IN (' . implode(',', $arr_obj) . ') ';
|
|||
|
|
} else {
|
|||
|
|
$s_local .= '';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//то, что размещено на домклик и не появилось в ads_stats
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_domclick_feed=1 AND id_add_user IN (" . implode(',', $users_sp) . ") $s_local LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arrayLocal[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return array_unique($arrayLocal);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function getAllSendedYandex($db_sphinx, $user_view, $users_sp) {
|
|||
|
|
$arr_obj = array();
|
|||
|
|
$s_local = '';
|
|||
|
|
$arrayLocal = array();
|
|||
|
|
|
|||
|
|
$sql_ads = "SELECT DISTINCT(`object_id`) FROM `ads_stats` WHERE `agency_id` = '$user_view->agencyId' AND `service_id` = 3";
|
|||
|
|
$rezAdsErrors = mysql_query($sql_ads);
|
|||
|
|
if (mysql_num_rows($rezAdsErrors) > 0) {
|
|||
|
|
while ($objAdsInfo = mysql_fetch_assoc($rezAdsErrors)) {
|
|||
|
|
$arr_obj[] = $objAdsInfo['object_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!empty($arr_obj)) {
|
|||
|
|
$s_local .= ' AND id NOT IN (' . implode(',', $arr_obj) . ') ';
|
|||
|
|
} else {
|
|||
|
|
$s_local .= '';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//то, что размещено на яндекс и не появилось в ads_stats
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_bn_feed=1 AND id_add_user IN (" . implode(',', $users_sp) . ") $s_local LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arrayLocal[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return array_unique($arrayLocal);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function getAllSended($db_sphinx, $user_view, $users_sp) {
|
|||
|
|
$arr_obj = array();
|
|||
|
|
$s_local = '';
|
|||
|
|
$arrayLocal = array();
|
|||
|
|
|
|||
|
|
$sql_ads = "SELECT DISTINCT(`object_id`) FROM `ads_stats` WHERE `agency_id` = '$user_view->agencyId' AND `service_id` = 1";
|
|||
|
|
$rezAdsErrors = mysql_query($sql_ads);
|
|||
|
|
if (mysql_num_rows($rezAdsErrors) > 0) {
|
|||
|
|
while ($objAdsInfo = mysql_fetch_assoc($rezAdsErrors)) {
|
|||
|
|
$arr_obj[] = $objAdsInfo['object_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!empty($arr_obj)) {
|
|||
|
|
$s_local .= ' AND id NOT IN (' . implode(',', $arr_obj) . ') ';
|
|||
|
|
} else {
|
|||
|
|
$s_local .= '';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//то, что размещено на авито и не появилось в ads_stats
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_avito_feed=1 AND id_add_user IN (" . implode(',', $users_sp) . ") $s_local LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arrayLocal[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$arr_obj = array();
|
|||
|
|
$s_local = '';
|
|||
|
|
|
|||
|
|
$sql_ads = "SELECT DISTINCT(`object_id`) FROM `ads_stats` WHERE `agency_id` = '$user_view->agencyId' AND `service_id` = 2";
|
|||
|
|
$rezAdsErrors = mysql_query($sql_ads);
|
|||
|
|
if (mysql_num_rows($rezAdsErrors) > 0) {
|
|||
|
|
while ($objAdsInfo = mysql_fetch_assoc($rezAdsErrors)) {
|
|||
|
|
$arr_obj[] = $objAdsInfo['object_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!empty($arr_obj)) {
|
|||
|
|
$s_local .= ' AND id NOT IN (' . implode(',', $arr_obj) . ') ';
|
|||
|
|
} else {
|
|||
|
|
$s_local .= '';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//то, что размещено на циан и не появилось в ads_stats
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_cian_feed=1 AND id_add_user IN (" . implode(',', $users_sp) . ") $s_local LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arrayLocal[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$arr_obj = array();
|
|||
|
|
$s_local = '';
|
|||
|
|
|
|||
|
|
$sql_ads = "SELECT DISTINCT(`object_id`) FROM `ads_stats` WHERE `agency_id` = '$user_view->agencyId' AND `service_id` = 4";
|
|||
|
|
$rezAdsErrors = mysql_query($sql_ads);
|
|||
|
|
if (mysql_num_rows($rezAdsErrors) > 0) {
|
|||
|
|
while ($objAdsInfo = mysql_fetch_assoc($rezAdsErrors)) {
|
|||
|
|
$arr_obj[] = $objAdsInfo['object_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!empty($arr_obj)) {
|
|||
|
|
$s_local .= ' AND id NOT IN (' . implode(',', $arr_obj) . ') ';
|
|||
|
|
} else {
|
|||
|
|
$s_local .= '';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//то, что размещено на домклик и не появилось в ads_stats
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_domclick_feed=1 AND id_add_user IN (" . implode(',', $users_sp) . ") $s_local LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arrayLocal[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$arr_obj = array();
|
|||
|
|
$s_local = '';
|
|||
|
|
|
|||
|
|
$sql_ads = "SELECT DISTINCT(`object_id`) FROM `ads_stats` WHERE `agency_id` = '$user_view->agencyId' AND `service_id` = 3";
|
|||
|
|
$rezAdsErrors = mysql_query($sql_ads);
|
|||
|
|
if (mysql_num_rows($rezAdsErrors) > 0) {
|
|||
|
|
while ($objAdsInfo = mysql_fetch_assoc($rezAdsErrors)) {
|
|||
|
|
$arr_obj[] = $objAdsInfo['object_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!empty($arr_obj)) {
|
|||
|
|
$s_local .= ' AND id NOT IN (' . implode(',', $arr_obj) . ') ';
|
|||
|
|
} else {
|
|||
|
|
$s_local .= '';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//то, что размещено на яндекс и не появилось в ads_stats
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_bn_feed=1 AND id_add_user IN (" . implode(',', $users_sp) . ") $s_local LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arrayLocal[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return array_unique($arrayLocal);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function get_inter_avito($user_view, $users_sp, $db_sphinx, $sended) {
|
|||
|
|
$arr_obj_avito = array();
|
|||
|
|
$arr_local = array();
|
|||
|
|
|
|||
|
|
$endSql = "";
|
|||
|
|
|
|||
|
|
if (count($sended) > 0) {
|
|||
|
|
$endSql = " AND `object_id` NOT IN (" . implode(',', $sended) . ")";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$sql_ads = "SELECT DISTINCT(`object_id`) FROM `ads_stats` WHERE `agency_id` = '$user_view->agencyId' AND `errors` IS NULL AND `object_id` NOT IN (SELECT s.`object_id` FROM `ads_stats` s WHERE s.`errors` IS NOT NULL AND s.`service_id` = 1) AND `service_id` = 1 " . $endSql;
|
|||
|
|
$rezAdsErrors = mysql_query($sql_ads);
|
|||
|
|
if (mysql_num_rows($rezAdsErrors) > 0) {
|
|||
|
|
while ($objAdsInfo = mysql_fetch_assoc($rezAdsErrors)) {
|
|||
|
|
$arr_obj_avito[] = $objAdsInfo['object_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!empty($arr_obj_avito)) {
|
|||
|
|
$s_local = ' AND id IN (' . implode(',', $arr_obj_avito) . ') ';
|
|||
|
|
|
|||
|
|
//то, что размещено на авито и появилось в ads_stats без ошибок
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_avito_feed=1 AND id_add_user IN (" . implode(',', $users_sp) . ") $s_local LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arr_local[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return array_unique($arr_local);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function get_inter_cian($user_view, $users_sp, $db_sphinx, $sended) {
|
|||
|
|
$arr_obj_cn = array();
|
|||
|
|
$arr_local = array();
|
|||
|
|
|
|||
|
|
$endSql = "";
|
|||
|
|
|
|||
|
|
if (count($sended) > 0) {
|
|||
|
|
$endSql = " AND `object_id` NOT IN (" . implode(',', $sended) . ")";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$sql_ads = "SELECT DISTINCT(`object_id`) FROM `ads_stats` WHERE `agency_id` = '$user_view->agencyId' AND `errors` IS NULL AND `object_id` NOT IN (SELECT s.`object_id` FROM `ads_stats` s WHERE s.`errors` IS NOT NULL AND s.`service_id` = 2) AND `service_id` = 2 " . $endSql;
|
|||
|
|
$rezAdsErrors = mysql_query($sql_ads);
|
|||
|
|
if (mysql_num_rows($rezAdsErrors) > 0) {
|
|||
|
|
while ($objAdsInfo = mysql_fetch_assoc($rezAdsErrors)) {
|
|||
|
|
$arr_obj_cn[] = $objAdsInfo['object_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!empty($arr_obj_cn)) {
|
|||
|
|
$s_local = ' AND id IN (' . implode(',', $arr_obj_cn) . ') ';
|
|||
|
|
|
|||
|
|
//то, что размещено на циан и появилось в ads_stats без ошибок
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_cian_feed=1 AND id_add_user IN (" . implode(',', $users_sp) . ") $s_local LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arr_local[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return array_unique($arr_local);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function get_inter_dom($user_view, $users_sp, $db_sphinx, $sended) {
|
|||
|
|
$arr_obj_dc = array();
|
|||
|
|
$arr_local = array();
|
|||
|
|
$arr_obj_err = array();
|
|||
|
|
|
|||
|
|
$endSql = "";
|
|||
|
|
$endSql2 = "";
|
|||
|
|
|
|||
|
|
$sql_ads_er = "SELECT DISTINCT(st.object_id) FROM ads_stats st WHERE st.agency_id = '$user_view->agencyId' AND st.errors IS NOT NULL AND st.service_id = 4";
|
|||
|
|
$rezAdsErrors = mysql_query($sql_ads_er);
|
|||
|
|
if (mysql_num_rows($rezAdsErrors) > 0) {
|
|||
|
|
while ($objAdsInfo = mysql_fetch_assoc($rezAdsErrors)) {
|
|||
|
|
$arr_obj_err[] = $objAdsInfo['object_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (count($arr_obj_err) > 0) {
|
|||
|
|
$endSql2 = " AND `object_id` NOT IN (" . implode(',', $arr_obj_err) . ")";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (count($sended) > 0) {
|
|||
|
|
$endSql = " AND `object_id` NOT IN (" . implode(',', $sended) . ")";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$sql_ads = "SELECT DISTINCT(`object_id`) FROM `ads_stats` WHERE `agency_id` = '$user_view->agencyId' AND `errors` IS NULL $endSql2 AND `service_id` = 4 " . $endSql;
|
|||
|
|
$rezAdsErrors = mysql_query($sql_ads);
|
|||
|
|
if (mysql_num_rows($rezAdsErrors) > 0) {
|
|||
|
|
while ($objAdsInfo = mysql_fetch_assoc($rezAdsErrors)) {
|
|||
|
|
$arr_obj_dc[] = $objAdsInfo['object_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!empty($arr_obj_dc)) {
|
|||
|
|
$s_local = ' AND id IN (' . implode(',', $arr_obj_dc) . ') ';
|
|||
|
|
|
|||
|
|
//то, что размещено на домклик и появилось в ads_stats без ошибок
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_domclick_feed=1 AND id_add_user IN (" . implode(',', $users_sp) . ") $s_local LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arr_local[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return array_unique($arr_local);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function get_inter_yandex($user_view, $users_sp, $db_sphinx, $sended) {
|
|||
|
|
$arr_obj_ya = array();
|
|||
|
|
$arr_local = array();
|
|||
|
|
|
|||
|
|
$endSql = "";
|
|||
|
|
|
|||
|
|
if (count($sended) > 0) {
|
|||
|
|
$endSql = " AND `object_id` NOT IN (" . implode(',', $sended) . ")";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$sql_ads = "SELECT DISTINCT(`object_id`) FROM `ads_stats` WHERE `agency_id` = '$user_view->agencyId' AND `errors` IS NULL AND `object_id` NOT IN (SELECT s.`object_id` FROM `ads_stats` s WHERE s.`errors` IS NOT NULL AND s.`service_id` = 3) AND `service_id` = 3 " . $endSql;
|
|||
|
|
$rezAdsErrors = mysql_query($sql_ads);
|
|||
|
|
if (mysql_num_rows($rezAdsErrors) > 0) {
|
|||
|
|
while ($objAdsInfo = mysql_fetch_assoc($rezAdsErrors)) {
|
|||
|
|
$arr_obj_ya[] = $objAdsInfo['object_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!empty($arr_obj_ya)) {
|
|||
|
|
$s_local = ' AND id IN (' . implode(',', $arr_obj_ya) . ') ';
|
|||
|
|
|
|||
|
|
//то, что размещено на яндекс и появилось в ads_stats без ошибок
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_bn_feed=1 AND id_add_user IN (" . implode(',', $users_sp) . ") $s_local LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arr_local[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return array_unique($arr_local);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function get_inter($user_view, $users_sp, $db_sphinx, $sended) {
|
|||
|
|
$arr_obj_avito = array();
|
|||
|
|
$arr_obj_cn = array();
|
|||
|
|
$arr_obj_dc = array();
|
|||
|
|
$arr_obj_ya = array();
|
|||
|
|
|
|||
|
|
$arr_obj_err = array();
|
|||
|
|
|
|||
|
|
$arr_local = array();
|
|||
|
|
$s_local = '';
|
|||
|
|
|
|||
|
|
$endSql = "";
|
|||
|
|
$endSql2 = "";
|
|||
|
|
|
|||
|
|
$sql_ads_er = "SELECT DISTINCT(st.object_id) FROM ads_stats st WHERE st.agency_id = '$user_view->agencyId' AND st.errors IS NOT NULL";
|
|||
|
|
$rezAdsErrors = mysql_query($sql_ads_er);
|
|||
|
|
if (mysql_num_rows($rezAdsErrors) > 0) {
|
|||
|
|
while ($objAdsInfo = mysql_fetch_assoc($rezAdsErrors)) {
|
|||
|
|
$arr_obj_err[] = $objAdsInfo['object_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (count($arr_obj_err) > 0) {
|
|||
|
|
$endSql2 = " AND `object_id` NOT IN (" . implode(',', $arr_obj_err) . ")";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (count($sended) > 0) {
|
|||
|
|
$endSql = " AND `object_id` NOT IN (" . implode(',', $sended) . ")";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$sql_ads = "SELECT DISTINCT(`object_id`) FROM `ads_stats` WHERE `agency_id` = '$user_view->agencyId' AND `errors` IS NULL $endSql2 AND `service_id` = 1 " . $endSql;
|
|||
|
|
$rezAdsErrors = mysql_query($sql_ads);
|
|||
|
|
if (mysql_num_rows($rezAdsErrors) > 0) {
|
|||
|
|
while ($objAdsInfo = mysql_fetch_assoc($rezAdsErrors)) {
|
|||
|
|
$arr_obj_avito[] = $objAdsInfo['object_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!empty($arr_obj_avito)) {
|
|||
|
|
$s_local = ' AND id IN (' . implode(',', $arr_obj_avito) . ') ';
|
|||
|
|
|
|||
|
|
//то, что размещено на авито и появилось в ads_stats без ошибок
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_avito_feed=1 AND id_add_user IN (" . implode(',', $users_sp) . ") $s_local LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arr_local[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$s_local = '';
|
|||
|
|
|
|||
|
|
$sql_ads = "SELECT DISTINCT(`object_id`) FROM `ads_stats` WHERE `agency_id` = '$user_view->agencyId' AND `errors` IS NULL $endSql2 AND `service_id` = 2 " . $endSql;
|
|||
|
|
$rezAdsErrors = mysql_query($sql_ads);
|
|||
|
|
if (mysql_num_rows($rezAdsErrors) > 0) {
|
|||
|
|
while ($objAdsInfo = mysql_fetch_assoc($rezAdsErrors)) {
|
|||
|
|
$arr_obj_cn[] = $objAdsInfo['object_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!empty($arr_obj_cn)) {
|
|||
|
|
$s_local = ' AND id IN (' . implode(',', $arr_obj_cn) . ') ';
|
|||
|
|
|
|||
|
|
//то, что размещено на циан и появилось в ads_stats без ошибок
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_cian_feed=1 AND id_add_user IN (" . implode(',', $users_sp) . ") $s_local LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arr_local[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$s_local = '';
|
|||
|
|
|
|||
|
|
$sql_ads = "SELECT DISTINCT(`object_id`) FROM `ads_stats` WHERE `agency_id` = '$user_view->agencyId' AND `errors` IS NULL $endSql2 AND `service_id` = 4 " . $endSql;
|
|||
|
|
$rezAdsErrors = mysql_query($sql_ads);
|
|||
|
|
if (mysql_num_rows($rezAdsErrors) > 0) {
|
|||
|
|
while ($objAdsInfo = mysql_fetch_assoc($rezAdsErrors)) {
|
|||
|
|
$arr_obj_dc[] = $objAdsInfo['object_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!empty($arr_obj_dc)) {
|
|||
|
|
$s_local = ' AND id IN (' . implode(',', $arr_obj_dc) . ') ';
|
|||
|
|
|
|||
|
|
//то, что размещено на домклик и появилось в ads_stats без ошибок
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_domclick_feed=1 AND id_add_user IN (" . implode(',', $users_sp) . ") $s_local LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arr_local[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$s_local = '';
|
|||
|
|
|
|||
|
|
$sql_ads = "SELECT DISTINCT(`object_id`) FROM `ads_stats` WHERE `agency_id` = '$user_view->agencyId' AND `errors` IS NULL $endSql2 AND `service_id` = 3 " . $endSql;
|
|||
|
|
$rezAdsErrors = mysql_query($sql_ads);
|
|||
|
|
if (mysql_num_rows($rezAdsErrors) > 0) {
|
|||
|
|
while ($objAdsInfo = mysql_fetch_assoc($rezAdsErrors)) {
|
|||
|
|
$arr_obj_ya[] = $objAdsInfo['object_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!empty($arr_obj_ya)) {
|
|||
|
|
$s_local = ' AND id IN (' . implode(',', $arr_obj_ya) . ') ';
|
|||
|
|
|
|||
|
|
//то, что размещено на яндекс и появилось в ads_stats без ошибок
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_bn_feed=1 AND id_add_user IN (" . implode(',', $users_sp) . ") $s_local LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arr_local[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return array_unique($arr_local);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// статус Отправлен и не выбрана площадка
|
|||
|
|
if ($post['ads_sended'] == '1' && $addToAvitoFilter <= 0 && $addToCianFilter <= 0 && $addToDomClickFilter <= 0 && $addToYandexFilter <= 0) {
|
|||
|
|
|
|||
|
|
$result = getAllSended($db_sphinx, $currentUser, $agentIds);
|
|||
|
|
|
|||
|
|
foreach ($result as $val) {
|
|||
|
|
$arrayFids[] = $val;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// статус Отправлен и выбрана площадка
|
|||
|
|
if ($post['ads_sended'] == '1' && ($addToAvitoFilter > 0 || $addToCianFilter > 0 || $addToDomClickFilter > 0 || $addToYandexFilter > 0)) {
|
|||
|
|
|
|||
|
|
if ($addToAvitoFilter > 0) {
|
|||
|
|
$arr_obj = array();
|
|||
|
|
$s_local = '';
|
|||
|
|
|
|||
|
|
$sql_ads = "SELECT DISTINCT(`object_id`) FROM `ads_stats` WHERE `agency_id` = '$currentUser->agencyId' AND `service_id` = 1";
|
|||
|
|
$rezAdsErrors = mysql_query($sql_ads);
|
|||
|
|
if (mysql_num_rows($rezAdsErrors) > 0) {
|
|||
|
|
while ($objAdsInfo = mysql_fetch_assoc($rezAdsErrors)) {
|
|||
|
|
$arr_obj[] = $objAdsInfo['object_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!empty($arr_obj)) {
|
|||
|
|
$s_local .= ' AND id NOT IN (' . implode(',', $arr_obj) . ') ';
|
|||
|
|
|
|||
|
|
//то, что размещено на авито и не появилось в ads_stats
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_avito_feed=1 AND id_add_user IN (" . implode(',', $agentIds) . ") $s_local LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arrayFids[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if ($addToCianFilter > 0) {
|
|||
|
|
$arr_obj = array();
|
|||
|
|
$s_local = '';
|
|||
|
|
|
|||
|
|
$sql_ads = "SELECT DISTINCT(`object_id`) FROM `ads_stats` WHERE `agency_id` = '$currentUser->agencyId' AND `service_id` = 2";
|
|||
|
|
$rezAdsErrors = mysql_query($sql_ads);
|
|||
|
|
if (mysql_num_rows($rezAdsErrors) > 0) {
|
|||
|
|
while ($objAdsInfo = mysql_fetch_assoc($rezAdsErrors)) {
|
|||
|
|
$arr_obj[] = $objAdsInfo['object_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!empty($arr_obj)) {
|
|||
|
|
//то, что размещено на циан и не появилось в ads_stats
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_cian_feed=1 AND id_add_user IN (" . implode(',', $agentIds) . ") $s_local LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arrayFids[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if ($addToDomClickFilter > 0) {
|
|||
|
|
$arr_obj = array();
|
|||
|
|
$s_local = '';
|
|||
|
|
|
|||
|
|
$sql_ads = "SELECT DISTINCT(`object_id`) FROM `ads_stats` WHERE `agency_id` = '$currentUser->agencyId' AND `service_id` = 4";
|
|||
|
|
$rezAdsErrors = mysql_query($sql_ads);
|
|||
|
|
if (mysql_num_rows($rezAdsErrors) > 0) {
|
|||
|
|
while ($objAdsInfo = mysql_fetch_assoc($rezAdsErrors)) {
|
|||
|
|
$arr_obj[] = $objAdsInfo['object_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!empty($arr_obj)) {
|
|||
|
|
//то, что размещено на домклик и не появилось в ads_stats
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_domclick_feed=1 AND id_add_user IN (" . implode(',', $agentIds) . ") $s_local LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arrayFids[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if ($addToYandexFilter > 0) {
|
|||
|
|
$arr_obj = array();
|
|||
|
|
$s_local = '';
|
|||
|
|
|
|||
|
|
$sql_ads = "SELECT DISTINCT(`object_id`) FROM `ads_stats` WHERE `agency_id` = '$currentUser->agencyId' AND `service_id` = 3";
|
|||
|
|
$rezAdsErrors = mysql_query($sql_ads);
|
|||
|
|
if (mysql_num_rows($rezAdsErrors) > 0) {
|
|||
|
|
while ($objAdsInfo = mysql_fetch_assoc($rezAdsErrors)) {
|
|||
|
|
$arr_obj[] = $objAdsInfo['object_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!empty($arr_obj)) {
|
|||
|
|
//то, что размещено на яндекс и не появилось в ads_stats
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_bn_feed=1 AND id_add_user IN (" . implode(',', $agentIds) . ") $s_local LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arrayFids[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// статус Размещается и не выбрана площадка
|
|||
|
|
if ($post['ads_good_adv'] == '1' && $addToAvitoFilter <= 0 && $addToCianFilter <= 0 && $addToDomClickFilter <= 0 && $addToYandexFilter <= 0) {
|
|||
|
|
|
|||
|
|
$result = getAllSended($db_sphinx, $currentUser, $agentIds);
|
|||
|
|
|
|||
|
|
$intersection = get_inter($currentUser, $agentIds, $db_sphinx, $result);
|
|||
|
|
|
|||
|
|
foreach ($intersection as $val) {
|
|||
|
|
$arrayFids[] = $val;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// статус Размещается и выбрана площадка
|
|||
|
|
if ($post['ads_good_adv'] == '1' && ($addToAvitoFilter > 0 || $addToCianFilter > 0 || $addToDomClickFilter > 0 || $addToYandexFilter > 0)) {
|
|||
|
|
|
|||
|
|
|
|||
|
|
if ($addToAvitoFilter > 0) {
|
|||
|
|
$allSended = getAllSendedAvito($db_sphinx, $currentUser, $agentIds);
|
|||
|
|
|
|||
|
|
$intersection = get_inter_avito($currentUser, $agentIds, $db_sphinx, $allSended);
|
|||
|
|
|
|||
|
|
$arr_obj = array();
|
|||
|
|
$s_local = '';
|
|||
|
|
|
|||
|
|
$sql_ads = "SELECT DISTINCT(`object_id`) FROM `ads_stats` WHERE `agency_id` = '$currentUser->agencyId' AND `errors` IS NULL AND `object_id` NOT IN (SELECT s.`object_id` FROM `ads_stats` s WHERE s.`errors` IS NOT NULL AND `service_id` = 1) AND `service_id` = 1";
|
|||
|
|
$rezAdsErrors = mysql_query($sql_ads);
|
|||
|
|
if (mysql_num_rows($rezAdsErrors) > 0) {
|
|||
|
|
while ($objAdsInfo = mysql_fetch_assoc($rezAdsErrors)) {
|
|||
|
|
$arr_obj[] = $objAdsInfo['object_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$arr_obj = array_intersect($arr_obj, $intersection);
|
|||
|
|
|
|||
|
|
if (!empty($arr_obj)) {
|
|||
|
|
$s_local = ' AND id IN (' . implode(',', $arr_obj) . ') ';
|
|||
|
|
|
|||
|
|
//то, что размещено на авито и появилось в ads_stats без ошибок
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_avito_feed=1 AND id_add_user IN (" . implode(',', $agentIds) . ") $s_local LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arrayFids[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if ($addToCianFilter > 0) {
|
|||
|
|
|
|||
|
|
$allSended = getAllSendedCian($db_sphinx, $currentUser, $agentIds);
|
|||
|
|
|
|||
|
|
$intersection = get_inter_cian($currentUser, $agentIds, $db_sphinx, $allSended);
|
|||
|
|
|
|||
|
|
$arr_obj = array();
|
|||
|
|
$s_local = '';
|
|||
|
|
|
|||
|
|
$sql_ads = "SELECT DISTINCT(`object_id`) FROM `ads_stats` WHERE `agency_id` = '$currentUser->agencyId' AND `errors` IS NULL AND `object_id` NOT IN (SELECT s.`object_id` FROM `ads_stats` s WHERE s.`errors` IS NOT NULL AND `service_id` = 2) AND `service_id` = 2";
|
|||
|
|
$rezAdsErrors = mysql_query($sql_ads);
|
|||
|
|
if (mysql_num_rows($rezAdsErrors) > 0) {
|
|||
|
|
while ($objAdsInfo = mysql_fetch_assoc($rezAdsErrors)) {
|
|||
|
|
$arr_obj[] = $objAdsInfo['object_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$arr_obj = array_intersect($arr_obj, $intersection);
|
|||
|
|
|
|||
|
|
if (!empty($arr_obj)) {
|
|||
|
|
$s_local = ' AND id IN (' . implode(',', $arr_obj) . ') ';
|
|||
|
|
|
|||
|
|
//то, что размещено на циан и появилось в ads_stats без ошибок
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_cian_feed=1 AND id_add_user IN (" . implode(',', $agentIds) . ") $s_local LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arrayFids[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if ($addToDomClickFilter > 0) {
|
|||
|
|
$allSended = getAllSendedDom($db_sphinx, $currentUser, $agentIds);
|
|||
|
|
|
|||
|
|
$intersection = get_inter_dom($currentUser, $agentIds, $db_sphinx, $allSended);
|
|||
|
|
|
|||
|
|
$arr_obj_err = array();
|
|||
|
|
|
|||
|
|
$endSql2 = "";
|
|||
|
|
|
|||
|
|
$sql_ads_er = "SELECT DISTINCT(st.object_id) FROM ads_stats st WHERE st.agency_id = '$currentUser->agencyId' AND st.errors IS NOT NULL AND st.service_id = 4";
|
|||
|
|
$rezAdsErrors = mysql_query($sql_ads_er);
|
|||
|
|
if (mysql_num_rows($rezAdsErrors) > 0) {
|
|||
|
|
while ($objAdsInfo = mysql_fetch_assoc($rezAdsErrors)) {
|
|||
|
|
$arr_obj_err[] = $objAdsInfo['object_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (count($arr_obj_err) > 0) {
|
|||
|
|
$endSql2 = " AND `object_id` NOT IN (" . implode(',', $arr_obj_err) . ")";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$arr_obj = array();
|
|||
|
|
$s_local = '';
|
|||
|
|
|
|||
|
|
$sql_ads = "SELECT DISTINCT(`object_id`) FROM `ads_stats` WHERE `agency_id` = '$currentUser->agencyId' AND `errors` IS NULL $endSql2 AND `service_id` = 4";
|
|||
|
|
$rezAdsErrors = mysql_query($sql_ads);
|
|||
|
|
if (mysql_num_rows($rezAdsErrors) > 0) {
|
|||
|
|
while ($objAdsInfo = mysql_fetch_assoc($rezAdsErrors)) {
|
|||
|
|
$arr_obj[] = $objAdsInfo['object_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$arr_obj = array_intersect($arr_obj, $intersection);
|
|||
|
|
|
|||
|
|
if (!empty($arr_obj)) {
|
|||
|
|
$s_local = ' AND id IN (' . implode(',', $arr_obj) . ') ';
|
|||
|
|
|
|||
|
|
//то, что размещено на домклик и появилось в ads_stats без ошибок
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_domclick_feed=1 AND id_add_user IN (" . implode(',', $agentIds) . ") $s_local LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arrayFids[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if ($addToYandexFilter > 0) {
|
|||
|
|
|
|||
|
|
$allSended = getAllSendedYandex($db_sphinx, $currentUser, $agentIds);
|
|||
|
|
|
|||
|
|
$intersection = get_inter_yandex($currentUser, $agentIds, $db_sphinx, $allSended);
|
|||
|
|
|
|||
|
|
$arr_obj = array();
|
|||
|
|
$s_local = '';
|
|||
|
|
|
|||
|
|
$sql_ads = "SELECT DISTINCT(`object_id`) FROM `ads_stats` WHERE `agency_id` = '$currentUser->agencyId' AND `errors` IS NULL AND `object_id` NOT IN (SELECT s.`object_id` FROM `ads_stats` s WHERE s.`errors` IS NOT NULL AND `service_id` = 3) AND `service_id` = 3";
|
|||
|
|
$rezAdsErrors = mysql_query($sql_ads);
|
|||
|
|
if (mysql_num_rows($rezAdsErrors) > 0) {
|
|||
|
|
while ($objAdsInfo = mysql_fetch_assoc($rezAdsErrors)) {
|
|||
|
|
$arr_obj[] = $objAdsInfo['object_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$arr_obj = array_intersect($arr_obj, $intersection);
|
|||
|
|
|
|||
|
|
if (!empty($arr_obj)) {
|
|||
|
|
$s_local = ' AND id IN (' . implode(',', $arr_obj) . ') ';
|
|||
|
|
|
|||
|
|
//то, что размещено на яндекс и появилось в ads_stats без ошибок
|
|||
|
|
$sql1 = "SELECT id FROM objects WHERE add_to_bn_feed=1 AND id_add_user IN (" . implode(',', $agentIds) . ") $s_local LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while ($r1 = $db_sphinx->fetch_assoc($q1)) {
|
|||
|
|
$arrayFids[] = $r1['id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//Статус Сняты с размещения
|
|||
|
|
if ($post['removed_publication'] == '1') {
|
|||
|
|
|
|||
|
|
$objects_unpublish = $object_publish = array('DOMCLICK_JW_FEED'=>array(), 'CIAN_JW_FEED'=>array(), 'AVITO_JW_FEED'=>array(), 'YANDEX_JW_FEED'=>array(), 'EMLS_JW_FEED'=>array());
|
|||
|
|
$publish_obj = array();
|
|||
|
|
$sql_publish = "SELECT * FROM object_publish_statistic WHERE on_moderation = 0 AND user_owner_id IN (" . implode(',', $agentIds) . ")";
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
$q_publish = mysql_query($sql_publish);
|
|||
|
|
while($obj_publish = mysql_fetch_assoc($q_publish)){
|
|||
|
|
if(isset($objects_unpublish[$obj_publish['destination']]) && !is_null($obj_publish['unpublish_user_id'])){
|
|||
|
|
$objects_unpublish[$obj_publish['destination']][] = (int)$obj_publish['object_id'];
|
|||
|
|
} else if (isset($object_publish[$obj_publish['destination']])){
|
|||
|
|
$object_publish[$obj_publish['destination']][] = (int)$obj_publish['object_id'];
|
|||
|
|
$publish_obj[] = (int)$obj_publish['object_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$time = microtime(true) - $start;
|
|||
|
|
if(isset($post['dev'])){
|
|||
|
|
///echo $sql_publish;
|
|||
|
|
echo 'Снято 1 --- '.$time." сек.";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
if(!empty($publish_obj)){
|
|||
|
|
$sql1 = "SELECT id, add_to_bn_feed, add_to_domclick_feed, add_to_cian_feed, add_to_avito_feed, add_to_emls_feed FROM objects WHERE id_add_user IN (" . implode(',', $agentIds) . ") AND id in (".implode(',', $publish_obj).") LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
|
|||
|
|
$q1 = $db_sphinx->query($sql1, true);
|
|||
|
|
while($r1 = $db_sphinx->fetch_assoc($q1)){
|
|||
|
|
if($r1['add_to_bn_feed'] == 0){
|
|||
|
|
if($index = array_search((int)$r1['id'], $object_publish['YANDEX_JW_FEED']) !== false){
|
|||
|
|
$objects_unpublish['YANDEX_JW_FEED'][] = (int)$r1['id'];
|
|||
|
|
unset($object_publish['YANDEX_JW_FEED'][$index]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if($r1['add_to_domclick_feed'] == 0){
|
|||
|
|
if($index = array_search((int)$r1['id'], $object_publish['DOMCLICK_JW_FEED']) !== false){
|
|||
|
|
$objects_unpublish['DOMCLICK_JW_FEED'][] = (int)$r1['id'];
|
|||
|
|
unset($object_publish['DOMCLICK_JW_FEED'][$index]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if($r1['add_to_cian_feed'] == 0){
|
|||
|
|
if($index = array_search((int)$r1['id'], $object_publish['CIAN_JW_FEED']) !== false){
|
|||
|
|
$objects_unpublish['CIAN_JW_FEED'][] = (int)$r1['id'];
|
|||
|
|
unset($object_publish['CIAN_JW_FEED'][$index]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if($r1['add_to_avito_feed'] == 0){
|
|||
|
|
if($index = array_search((int)$r1['id'], $object_publish['AVITO_JW_FEED']) !== false){
|
|||
|
|
$objects_unpublish['AVITO_JW_FEED'][] = (int)$r1['id'];
|
|||
|
|
unset($object_publish['AVITO_JW_FEED'][$index]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if($r1['add_to_emls_feed'] == 0){
|
|||
|
|
if($index = array_search((int)$r1['id'], $object_publish['EMLS_JW_FEED']) !== false){
|
|||
|
|
$objects_unpublish['EMLS_JW_FEED'][] = (int)$r1['id'];
|
|||
|
|
unset($object_publish['EMLS_JW_FEED'][$index]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
/* if($r1['add_to_yandex_feed'] == 0){
|
|||
|
|
if($index = array_search((int)$r1['id'], $object_publish['FREE_JW_FEED']) !== false){
|
|||
|
|
$objects_unpublish['FREE_JW_FEED'][] = (int)$r1['id'];
|
|||
|
|
unset($object_publish['FREE_JW_FEED'][$index]);
|
|||
|
|
}
|
|||
|
|
}*/
|
|||
|
|
}
|
|||
|
|
$time = microtime(true) - $start;
|
|||
|
|
if(isset($post['dev'])){
|
|||
|
|
echo 'Снято 2 --- '.$time." сек.";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
if($addToAvitoFilter <= 0 && $addToCianFilter <= 0 && $addToDomClickFilter <= 0 && $addToYandexFilter <= 0 && $addToEMLSFilter <= 0){
|
|||
|
|
foreach($objects_unpublish as $plase => $objects){
|
|||
|
|
|
|||
|
|
foreach($objects as $object_ad){
|
|||
|
|
|
|||
|
|
if(!in_array($object_ad, $object_publish[$plase])){
|
|||
|
|
$arrayFids[] = $object_ad;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
|
|||
|
|
if ($addToAvitoFilter > 0) {
|
|||
|
|
foreach($objects_unpublish['AVITO_JW_FEED'] as $object_ad){
|
|||
|
|
|
|||
|
|
if(!in_array($object_ad, $object_publish['AVITO_JW_FEED'])){
|
|||
|
|
$arrayFids[] = $object_ad;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($addToCianFilter > 0) {
|
|||
|
|
|
|||
|
|
foreach($objects_unpublish['CIAN_JW_FEED'] as $object_ad){
|
|||
|
|
|
|||
|
|
if(!in_array($object_ad, $object_publish['CIAN_JW_FEED'])){
|
|||
|
|
$arrayFids[] = $object_ad;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($addToDomClickFilter > 0) {
|
|||
|
|
|
|||
|
|
foreach($objects_unpublish['DOMCLICK_JW_FEED'] as $object_ad){
|
|||
|
|
|
|||
|
|
if(!in_array($object_ad, $object_publish['DOMCLICK_JW_FEED'])){
|
|||
|
|
$arrayFids[] = $object_ad;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($addToEMLSFilter > 0) {
|
|||
|
|
foreach($objects_unpublish['EMLS_JW_FEED'] as $object_ad){
|
|||
|
|
|
|||
|
|
if(!in_array($object_ad, $object_publish['EMLS_JW_FEED'])){
|
|||
|
|
$arrayFids[] = $object_ad;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($addToYandexFilter > 0) {
|
|||
|
|
foreach($objects_unpublish['YANDEX_JW_FEED'] as $object_ad){
|
|||
|
|
|
|||
|
|
if(!in_array($object_ad, $object_publish['YANDEX_JW_FEED'])){
|
|||
|
|
$arrayFids[] = $object_ad;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
$arrayFids = array_unique($arrayFids);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$time = microtime(true) - $start;
|
|||
|
|
if(isset($post['dev'])){
|
|||
|
|
echo 'Cyznj --- '.$time." сек.";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
if(!empty($arrayFids)){
|
|||
|
|
$arrayFids = array_unique($arrayFids);
|
|||
|
|
$s_3 = " AND id IN (" . implode(',', $arrayFids) . ")";
|
|||
|
|
} else if ($post['ads_errors'] > 0 || $post['ads_sended'] > 0 || $post['ads_good_adv'] > 0 || $post['removed_publication'] > 0){
|
|||
|
|
$s_3 = " AND id IN (0)";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$promotion = false;
|
|||
|
|
$sqlPr = '';
|
|||
|
|
|
|||
|
|
if(isset($_POST['avito_highlight']) && (int) $_POST['avito_highlight'] > 0){
|
|||
|
|
$sqlPr .= ' avito_highlight=1 OR ';
|
|||
|
|
$promotion = true;
|
|||
|
|
}
|
|||
|
|
if(isset($_POST['avito_xl']) && (int) $_POST['avito_xl'] > 0){
|
|||
|
|
$sqlPr .= ' avito_xl=1 OR ';
|
|||
|
|
$promotion = true;
|
|||
|
|
}
|
|||
|
|
if(isset($_POST['avito_x2_1']) && (int) $_POST['avito_x2_1'] > 0){
|
|||
|
|
$sqlPr .= ' avito_x2_1=1 OR ';
|
|||
|
|
$promotion = true;
|
|||
|
|
}
|
|||
|
|
if(isset($_POST['avito_x2_7']) && (int) $_POST['avito_x2_7'] > 0){
|
|||
|
|
$sqlPr .= ' avito_x2_7=1 OR ';
|
|||
|
|
$promotion = true;
|
|||
|
|
}
|
|||
|
|
if(isset($_POST['avito_x5_1']) && (int) $_POST['avito_x5_1'] > 0){
|
|||
|
|
$sqlPr .= ' avito_x5_1=1 OR ';
|
|||
|
|
$promotion = true;
|
|||
|
|
}
|
|||
|
|
if(isset($_POST['avito_x5_7']) && (int) $_POST['avito_x5_7'] > 0){
|
|||
|
|
$sqlPr .= ' avito_x5_7=1 OR ';
|
|||
|
|
$promotion = true;
|
|||
|
|
}
|
|||
|
|
if(isset($_POST['avito_x10_1']) && (int) $_POST['avito_x10_1'] > 0){
|
|||
|
|
$sqlPr .= ' avito_x10_1=1 OR ';
|
|||
|
|
$promotion = true;
|
|||
|
|
}
|
|||
|
|
if(isset($_POST['avito_x10_7']) && (int) $_POST['avito_x10_7'] > 0){
|
|||
|
|
$sqlPr .= ' avito_x10_7=1 OR ';
|
|||
|
|
$promotion = true;
|
|||
|
|
}
|
|||
|
|
if(isset($_POST['cian_highlight']) && (int) $_POST['cian_highlight'] > 0){
|
|||
|
|
$sqlPr .= ' cian_highlight=1 OR ';
|
|||
|
|
$promotion = true;
|
|||
|
|
}
|
|||
|
|
if(isset($_POST['cian_standard']) && (int) $_POST['cian_standard'] > 0){
|
|||
|
|
$sqlPr .= ' cian_standard=1 OR ';
|
|||
|
|
$promotion = true;
|
|||
|
|
}
|
|||
|
|
if(isset($_POST['cian_paid']) && (int) $_POST['cian_paid'] > 0){
|
|||
|
|
$sqlPr .= ' cian_paid=1 OR ';
|
|||
|
|
$promotion = true;
|
|||
|
|
}
|
|||
|
|
if(isset($_POST['cian_premium']) && (int) $_POST['cian_premium'] > 0){
|
|||
|
|
$sqlPr .= ' cian_premium=1 OR ';
|
|||
|
|
$promotion = true;
|
|||
|
|
}
|
|||
|
|
if(isset($_POST['cian_top3']) && (int) $_POST['cian_top3'] > 0){
|
|||
|
|
$sqlPr .= ' cian_top3=1 OR ';
|
|||
|
|
$promotion = true;
|
|||
|
|
}
|
|||
|
|
if(isset($_POST['cian_bet']) && (int) $_POST['cian_bet'] > 0){
|
|||
|
|
$sqlPr .= " cian_bet='".$_POST['cian_bet']."' OR ";
|
|||
|
|
$promotion = true;
|
|||
|
|
}
|
|||
|
|
if(isset($_POST['cian_ignore_pkg']) && (int) $_POST['cian_ignore_pkg'] > 0){
|
|||
|
|
$sqlPr .= " cian_ignore_pkg=1 OR ";
|
|||
|
|
$promotion = true;
|
|||
|
|
}
|
|||
|
|
if(isset($_POST['yandex_premium']) && (int) $_POST['yandex_premium'] > 0){
|
|||
|
|
$sqlPr .= " yandex_premium=1 OR ";
|
|||
|
|
$promotion = true;
|
|||
|
|
}
|
|||
|
|
if(isset($_POST['yandex_raise']) && (int) $_POST['yandex_raise'] > 0){
|
|||
|
|
$sqlPr .= " yandex_raise=1 OR ";
|
|||
|
|
$promotion = true;
|
|||
|
|
}
|
|||
|
|
if(isset($_POST['yandex_promotion']) && (int) $_POST['yandex_promotion'] > 0){
|
|||
|
|
$sqlPr .= " yandex_promotion=1 OR ";
|
|||
|
|
$promotion = true;
|
|||
|
|
}
|
|||
|
|
if(isset($_POST['domclick_express']) && (int) $_POST['domclick_express'] > 0){
|
|||
|
|
$sqlPr .= " domclick_express=1 OR ";
|
|||
|
|
$promotion = true;
|
|||
|
|
}
|
|||
|
|
if(isset($_POST['domclick_premium']) && (int) $_POST['domclick_premium'] > 0){
|
|||
|
|
$sqlPr .= " domclick_premium=1 OR ";
|
|||
|
|
$promotion = true;
|
|||
|
|
}
|
|||
|
|
if(isset($_POST['domclick_top']) && (int) $_POST['domclick_top'] > 0){
|
|||
|
|
$sqlPr .= " domclick_top=1 OR ";
|
|||
|
|
$promotion = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($sqlPr !== '') {
|
|||
|
|
$sqlPr = substr($sqlPr, 0, strlen($sqlPr) - 3);
|
|||
|
|
$sqlPr = " ($sqlPr) ";
|
|||
|
|
}
|
|||
|
|
$arrPromo = array();
|
|||
|
|
if($sqlPr !== ''){
|
|||
|
|
$sqlPr = "SELECT object_id FROM ads_promo WHERE {$sqlPr} AND (agency_id={$user->agencyId} or created_by IN (" . implode(',', $agentIds) . "))";
|
|||
|
|
$qpr = mysql_query($sqlPr);
|
|||
|
|
while($rpr = mysql_fetch_assoc($qpr)){
|
|||
|
|
$arrPromo[] = (int)$rpr['object_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$s_9 = '';
|
|||
|
|
if(!empty($arrPromo)){
|
|||
|
|
$s_9 = " AND id IN (" . implode(',', $arrPromo) . ")";
|
|||
|
|
} else if ($promotion){
|
|||
|
|
$s_9 = " 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 ';
|
|||
|
|
|
|||
|
|
if (!empty($arr_pac))
|
|||
|
|
$s_3 .= ' AND id NOT IN ('.implode(',', $arr_pac).') ';
|
|||
|
|
|
|||
|
|
}*/
|
|||
|
|
|
|||
|
|
$str_usl_bd .= $s_3.$s_4.$s_5.$s_7.$s_9;
|
|||
|
|
|
|||
|
|
if (isset($post['search'])) {
|
|||
|
|
$post['search'] = mb_strtolower(trim($post['search']), "UTF-8");
|
|||
|
|
if (preg_match('/^\d+$/', $post['search']))
|
|||
|
|
$str_usl_bd .= " AND id = ".$post['search'];
|
|||
|
|
else
|
|||
|
|
$str_usl_bd .= " AND MATCH ('@adres ".str_replace("/","-",$post['search'])."')";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$sql_count_sale = "SELECT id, IF(ads_avito_error = 1 OR ads_cian_error = 1 OR ads_yandex_error = 1 OR ads_domclick_error = 1, 1, 0) AS ads_error
|
|||
|
|
FROM objects
|
|||
|
|
WHERE del=0 and black <> 1 AND
|
|||
|
|
moder <> 1 AND
|
|||
|
|
operation_type = 1
|
|||
|
|
$str_usl_bd $str_usl_dealType
|
|||
|
|
LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
/*if($_SESSION['id'] == 8038){
|
|||
|
|
// ini_set('display_errors', 1);
|
|||
|
|
//error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE);
|
|||
|
|
echo $sql_count_sale;
|
|||
|
|
// die();
|
|||
|
|
}*/
|
|||
|
|
|
|||
|
|
if(isset($post['dev'])){
|
|||
|
|
echo $sql_count_sale;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$vsego_sale = $db_sphinx->num_rows($db_sphinx->query($sql_count_sale, true));
|
|||
|
|
|
|||
|
|
$sql_count_rent = "SELECT id, IF(ads_avito_error = 1 OR ads_cian_error = 1 OR ads_yandex_error = 1 OR ads_domclick_error = 1, 1, 0) AS ads_error
|
|||
|
|
FROM objects
|
|||
|
|
WHERE del=0 and black <> 1 AND
|
|||
|
|
moder <> 1 AND
|
|||
|
|
operation_type = 0
|
|||
|
|
$str_usl_bd
|
|||
|
|
LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
|
|||
|
|
$vsego_rent = $db_sphinx->num_rows($db_sphinx->query($sql_count_rent, true));
|
|||
|
|
|
|||
|
|
$str_usl_bd = $str_usl_bd . $str_usl_dealType;
|
|||
|
|
|
|||
|
|
if ($post['sale'] == 1) {
|
|||
|
|
$str_usl_bd = " AND operation_type = 1 ".$str_usl_bd;
|
|||
|
|
} else if ($post['rent'] == 1) {
|
|||
|
|
$str_usl_bd = " AND operation_type = 0 ".$str_usl_bd;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
$per_page = 10;
|
|||
|
|
if (isset($post['view']) && $post['view'] == 'table'){
|
|||
|
|
$per_page = 20;
|
|||
|
|
}
|
|||
|
|
if ($_SESSION['id'] == 93) {
|
|||
|
|
$per_page = 5;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$sql_count = "SELECT id, IF(ads_avito_error = 1 OR ads_cian_error = 1 OR ads_yandex_error = 1 OR ads_domclick_error = 1, 1, 0) AS ads_error
|
|||
|
|
FROM objects
|
|||
|
|
WHERE del=0 and black <> 1 AND
|
|||
|
|
moder <> 1
|
|||
|
|
$str_usl_bd
|
|||
|
|
LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
|
|||
|
|
/*if($_SESSION['id'] == 8826){
|
|||
|
|
echo $sql_count;
|
|||
|
|
}*/
|
|||
|
|
|
|||
|
|
|
|||
|
|
$vsego = $db_sphinx->num_rows($db_sphinx->query($sql_count, true));
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
$all_pages = ceil($vsego / $per_page);
|
|||
|
|
|
|||
|
|
if ($post['page']){
|
|||
|
|
$page = intval($post['page']);
|
|||
|
|
if($all_pages < $page && $page > 0){
|
|||
|
|
$page = $page - 1;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
$page = 1;
|
|||
|
|
|
|||
|
|
$limit = ($page - 1) * $per_page;
|
|||
|
|
|
|||
|
|
/* $sql = "SELECT objects.*,
|
|||
|
|
rayon.rayon,
|
|||
|
|
ads_objects.ads_id,
|
|||
|
|
ads_objects.ads_source,
|
|||
|
|
ads_objects.ads_agent,
|
|||
|
|
ads_objects.ads_url,
|
|||
|
|
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,
|
|||
|
|
IF((SELECT count(id) FROM ads_stats WHERE object_id = o.id AND is_error = 1) > 0, 1, 0) as ads_error,
|
|||
|
|
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
|
|||
|
|
LEFT JOIN ads_objects ON ads_objects.obj_id = objects.id
|
|||
|
|
WHERE objects.black <> 1 AND
|
|||
|
|
objects.moder <> 1 AND
|
|||
|
|
$str_usl_bd
|
|||
|
|
GROUP BY objects.id
|
|||
|
|
$order
|
|||
|
|
LIMIT $limit, $per_page";*/
|
|||
|
|
|
|||
|
|
if (isset($_SESSION['my_objects_export']) && isset($post['view']) && $post['view'] == 'table') {
|
|||
|
|
unset($_SESSION['my_objects_export']);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$sql = "SELECT *, IF(ads_avito_error = 1 OR ads_cian_error = 1 OR ads_yandex_error = 1 OR ads_domclick_error = 1, 1, 0) AS ads_error
|
|||
|
|
FROM objects
|
|||
|
|
WHERE del=0 and black <> 1 AND
|
|||
|
|
moder <> 1
|
|||
|
|
$str_usl_bd
|
|||
|
|
|
|||
|
|
$order
|
|||
|
|
LIMIT $limit, $per_page OPTION max_matches=1000000";
|
|||
|
|
if($post['view'] == 'table'){
|
|||
|
|
$sql = "SELECT *, IF(ads_avito_error = 1 OR ads_cian_error = 1 OR ads_yandex_error = 1 OR ads_domclick_error = 1, 1, 0) AS ads_error
|
|||
|
|
FROM objects
|
|||
|
|
WHERE del=0 and black <> 1 AND
|
|||
|
|
moder <> 1
|
|||
|
|
$str_usl_bd
|
|||
|
|
|
|||
|
|
$order
|
|||
|
|
LIMIT 1000000
|
|||
|
|
OPTION max_matches=1000000";
|
|||
|
|
}
|
|||
|
|
if(isset($post['dev'])){
|
|||
|
|
echo $sql;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$rez = $db_sphinx->query($sql, true);
|
|||
|
|
if ($db_sphinx->num_rows($rez)) {
|
|||
|
|
$_SESSION['my_objects_export'] = "SELECT *
|
|||
|
|
FROM objects
|
|||
|
|
WHERE del=0 and black <> 1 AND
|
|||
|
|
moder <> 1
|
|||
|
|
$str_usl_bd
|
|||
|
|
LIMIT 1000000
|
|||
|
|
OPTION max_matches=1000000";
|
|||
|
|
if($post['view'] != 'table'){
|
|||
|
|
?>
|
|||
|
|
<div class="f-system_pagination" style="margin-top: 15px;margin-bottom: 15px;">
|
|||
|
|
<table style="width: 100%">
|
|||
|
|
<tr>
|
|||
|
|
<td>
|
|||
|
|
<ul class="pagination" style="display: inline-flex;">
|
|||
|
|
<?php
|
|||
|
|
$str_url_add = "";
|
|||
|
|
if (isset($_GET['archive']))
|
|||
|
|
$mas_url_add[] = "archive=1";
|
|||
|
|
|
|||
|
|
if (isset($_GET['id_agent']))
|
|||
|
|
$mas_url_add[] = "id_agent=" . $_GET['id_agent'];
|
|||
|
|
|
|||
|
|
if (isset($_GET['potential']))
|
|||
|
|
$mas_url_add[] = "potential=1";
|
|||
|
|
|
|||
|
|
if (isset($_GET['ad']))
|
|||
|
|
$mas_url_add[] = "ad=1";
|
|||
|
|
|
|||
|
|
if (isset($_GET['obj_type']))
|
|||
|
|
$mas_url_add[] = "obj_type=" . $_GET['obj_type'];
|
|||
|
|
|
|||
|
|
if (isset($_GET['sale']))
|
|||
|
|
$mas_url_add[] = "sale=1";
|
|||
|
|
|
|||
|
|
if (isset($_GET['view']))
|
|||
|
|
$mas_url_add[] = "view=" . $_GET['view'];
|
|||
|
|
|
|||
|
|
if (isset($_GET['favor']))
|
|||
|
|
$mas_url_add[] = "favor=1";
|
|||
|
|
|
|||
|
|
if (!empty($mas_url_add))
|
|||
|
|
$str_url_add = implode("&", $mas_url_add);
|
|||
|
|
|
|||
|
|
if ($all_pages > 1) {
|
|||
|
|
num_of_pages($page, $all_pages, $str_url_add);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!$post['page_ap'])
|
|||
|
|
$post['page_ap'] = 1;
|
|||
|
|
|
|||
|
|
$next_page_ap = $_GET['page_ap'] + 1;
|
|||
|
|
?>
|
|||
|
|
<div class="clear"></div>
|
|||
|
|
</ul>
|
|||
|
|
<?php
|
|||
|
|
if ($all_pages > 1) {
|
|||
|
|
echo '<span style="padding-left: 15px; float: none; border: none;" class="control-group kol_find">перейти на <input type="number" maxlength="6" class="number text small-input no-mrg-left" placeholder="№ стр." onkeypress="goToObjectsPage(event, this)"/></span>';
|
|||
|
|
}
|
|||
|
|
?>
|
|||
|
|
</td>
|
|||
|
|
<td>
|
|||
|
|
<div style="position:relative;display:inline-block;float:right;margin-top:10px;">
|
|||
|
|
<div id="objectsSortOrder" class="form-block" style="float: right; width: 435px;">
|
|||
|
|
<?php
|
|||
|
|
$sort_order = false;
|
|||
|
|
if (isset($_SESSION['my_objects_sort_order'])) {
|
|||
|
|
$sort_order = $_SESSION['my_objects_sort_order'];
|
|||
|
|
}
|
|||
|
|
?>
|
|||
|
|
<div class="label" style="width: 120px;">Сортировка:</div>
|
|||
|
|
<div class="inputs" style="width: 68%;">
|
|||
|
|
<select name="my_objects_sort_order" style="width:100%;margin-top:3px;">
|
|||
|
|
<option value="0"<?php echo ((!$sort_order) ? " selected" : "") ?>>Дата изм. от нового к старому</option>
|
|||
|
|
<option value="1"<?php echo (($sort_order == "1") ? " selected" : "") ?>>Дата изм. от старого к новому</option>
|
|||
|
|
<option value="2"<?php echo (($sort_order == "2") ? " selected" : "") ?>>Дата доб. от нового к старому</option>
|
|||
|
|
<option value="3"<?php echo (($sort_order == "3") ? " selected" : "") ?>>Дата доб. от старого к новому</option>
|
|||
|
|
<option value="4"<?php echo (($sort_order == "4") ? " selected" : "") ?>>Дешевле</option>
|
|||
|
|
<option value="5"<?php echo (($sort_order == "5") ? " selected" : "") ?>>Дороже</option>
|
|||
|
|
</select>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
</td>
|
|||
|
|
</tr>
|
|||
|
|
</table>
|
|||
|
|
</div>
|
|||
|
|
<?php
|
|||
|
|
}
|
|||
|
|
$time = microtime(true) - $start;
|
|||
|
|
if(isset($post['dev'])){
|
|||
|
|
echo $time." сек.";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($_COOKIE['debug_spd']) { echo '<script>console.log(`ajax/getObjectsView.php:968 '.microtime(true).'`)</script>'; }
|
|||
|
|
if (isset($post['view']) && $post['view'] == 'table') {
|
|||
|
|
$arrIdWhoWork[] = "who_work IN (" . implode(',', $agentIds) . ")";
|
|||
|
|
$arrIdAddUsers[] = "id_add_user IN (" . implode(',', $agentIds) . ")";
|
|||
|
|
$usersIdReal[] = $agentIds;
|
|||
|
|
$userInStats = $agentIds; // ???
|
|||
|
|
|
|||
|
|
include($_SERVER['DOCUMENT_ROOT'] . "/templates/system__object_table_header.php");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//$notes_bd_usl = "created_by IN (" . implode(",", $agentIds) . ")";
|
|||
|
|
$agency_id = $user->agencyId;
|
|||
|
|
$menegersCheck = array();
|
|||
|
|
$usersIds = array();
|
|||
|
|
$users_phone2 = array();
|
|||
|
|
$sql_check_manager = "SELECT id, `id_manager`, first_name, last_name, middle_name, phone2 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)))";
|
|||
|
|
$result_check_manager = mysql_query($sql_check_manager);
|
|||
|
|
while($mng = mysql_fetch_assoc($result_check_manager)){
|
|||
|
|
$menegersCheck[$mng['id']] = $mng;
|
|||
|
|
$usersIds[] = (int)$mng['id'];
|
|||
|
|
if(!empty($mng['phone2'])){
|
|||
|
|
$users_phone2[$mng['id']] = $mng['phone2'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (isset($_SESSION['notes_bd_usl'])) {
|
|||
|
|
$notes_bd_usl = $_SESSION['notes_bd_usl'];
|
|||
|
|
} else {
|
|||
|
|
|
|||
|
|
|
|||
|
|
$usersIds = User::getAllAgencyUsers($agencyId);
|
|||
|
|
$usersIds[] = $_SESSION['id'];
|
|||
|
|
$usersIds = array_unique($usersIds);
|
|||
|
|
|
|||
|
|
$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;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$sql_check = "
|
|||
|
|
SELECT iframe_enabled
|
|||
|
|
FROM object_iframe
|
|||
|
|
WHERE agency_id = $agency_id
|
|||
|
|
";
|
|||
|
|
$result_enabled = mysql_query($sql_check);
|
|||
|
|
$iframe_enabled = mysql_fetch_assoc($result_enabled);
|
|||
|
|
|
|||
|
|
$objSphinx = array();
|
|||
|
|
$ids = array();
|
|||
|
|
$id_users_add = array();
|
|||
|
|
// $users_phone2 = array();
|
|||
|
|
$rayonIds = array();
|
|||
|
|
while($obj = $db_sphinx->fetch_assoc($rez)) {
|
|||
|
|
$ids[] = $obj['id'];
|
|||
|
|
$id_users_add[] = $obj['id_add_user'];
|
|||
|
|
$objSphinx[$obj['id']] = $obj;
|
|||
|
|
if($obj['rayon_id'] > 0){
|
|||
|
|
$rayonIds[] = (int)$obj['rayon_id'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
/*if($post['is_custom'] == 0){
|
|||
|
|
$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'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}*/
|
|||
|
|
|
|||
|
|
if($post['view'] != 'table'){
|
|||
|
|
$sql = "SELECT objects.*,
|
|||
|
|
rayon.rayon,
|
|||
|
|
ads_objects.ads_id,
|
|||
|
|
ads_objects.ads_source,
|
|||
|
|
ads_objects.ads_agent,
|
|||
|
|
ads_objects.ads_url,
|
|||
|
|
osp.site_published,
|
|||
|
|
$additional_select
|
|||
|
|
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
|
|||
|
|
$additional_join
|
|||
|
|
LEFT JOIN rayon rayon on objects.rayon = rayon.id
|
|||
|
|
LEFT JOIN land_usage_type lu on objects.land_usage_type_id = lu.id
|
|||
|
|
LEFT JOIN ads_objects ON ads_objects.obj_id = objects.id
|
|||
|
|
LEFT JOIN objects_site_published osp ON osp.object_id = objects.id
|
|||
|
|
WHERE objects.id in (" . implode(", ", $ids) .") $orderSql";
|
|||
|
|
|
|||
|
|
$rez = mysql_query($sql);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//начитка доп. инфы списком
|
|||
|
|
$rezAddInfoArray = [];
|
|||
|
|
if($post['view'] != 'table'){
|
|||
|
|
$sqlAddInfo = "SELECT oai.object_id, oai.apartments,
|
|||
|
|
oai.video_url,
|
|||
|
|
oai.balcony,
|
|||
|
|
oai.loggias,
|
|||
|
|
oai.separate_wcs,
|
|||
|
|
oai.combined_wcs,
|
|||
|
|
oai.passenger_lifts,
|
|||
|
|
oai.cargo_lifts,
|
|||
|
|
oai.window_view,
|
|||
|
|
oai.renovation,
|
|||
|
|
oai.ceiling_height,
|
|||
|
|
oai.vat_type_id,
|
|||
|
|
oai.house_category,
|
|||
|
|
oai.commission_agency,
|
|||
|
|
oai.commission_agency_type,
|
|||
|
|
clc.name as commerc_land_category_name,
|
|||
|
|
oai.flat_number,
|
|||
|
|
oai.building_area
|
|||
|
|
FROM objects_additional_information oai
|
|||
|
|
LEFT JOIN commerc_land_category clc on oai.commerc_land_category_id = clc.id
|
|||
|
|
WHERE object_id in (" . implode(", ", $ids) .")";
|
|||
|
|
$rezAddInfo = mysql_query($sqlAddInfo);
|
|||
|
|
if (mysql_num_rows($rezAddInfo) > 0) {
|
|||
|
|
while ($objAddInfo = mysql_fetch_assoc($rezAddInfo)) {
|
|||
|
|
$rezAddInfoArray[$objAddInfo["object_id"]] = $objAddInfo;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$time = microtime(true) - $start;
|
|||
|
|
if(isset($post['dev'])){
|
|||
|
|
$time = microtime(true) - $start;
|
|||
|
|
echo "\n".'объектов '. $time." сек.";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//if($post['view'] != 'table'){
|
|||
|
|
//начитка тегов списком
|
|||
|
|
$rezActivityArray = [];
|
|||
|
|
$rezActivityTableArray = [];
|
|||
|
|
$sqlAddInfo = "SELECT object_id, activity_id, (SELECT name FROM `activities` where objects_activities.activity_id = activities.id) as tag 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"]] = [];
|
|||
|
|
$rezActivityTableArray[$objActivity["object_id"]] = [];
|
|||
|
|
}
|
|||
|
|
$rezActivityArray[$objActivity["object_id"]][] = $objActivity["activity_id"];
|
|||
|
|
$rezActivityTableArray[$objActivity["object_id"]][] = $objActivity["tag"];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
$time = microtime(true) - $start;
|
|||
|
|
if(isset($post['dev'])){
|
|||
|
|
$time = microtime(true) - $start;
|
|||
|
|
echo "\n".'теги '. $time." сек.";
|
|||
|
|
}
|
|||
|
|
// }
|
|||
|
|
|
|||
|
|
//начитка фото списком
|
|||
|
|
$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"];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$time = microtime(true) - $start;
|
|||
|
|
if(isset($post['dev'])){
|
|||
|
|
$time = microtime(true) - $start;
|
|||
|
|
echo "\n".'фото '. $time." сек.";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
if($post['view'] != 'table'){
|
|||
|
|
//начитываем ошибки размещения объектов в рекламе
|
|||
|
|
$objAdsErrors = [];
|
|||
|
|
$objAdsSended = [];
|
|||
|
|
$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']);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//начитываем размещения объектов в рекламе
|
|||
|
|
$sql_ads = "SELECT `object_id`, `service_id`, `errors`, `url` FROM `ads_stats` WHERE `agency_id` = '$agency_id' AND `object_id` IN (" . implode(", ", $ids) .") AND `errors` IS 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'];
|
|||
|
|
$objAdsSended[$object_id][$service_id] = $objAdsInfo['url'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$time = microtime(true) - $start;
|
|||
|
|
if(isset($post['dev'])){
|
|||
|
|
$time = microtime(true) - $start;
|
|||
|
|
echo "\n".'ошибки '. $time." сек.";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//начитываем координаты списком
|
|||
|
|
$objCoordinatesArray = [];
|
|||
|
|
$objCoordinatesArrayTable = array();
|
|||
|
|
$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;
|
|||
|
|
$objCoordinatesArrayTable[$objCoords['object_id']] = $objCoords;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$time = microtime(true) - $start;
|
|||
|
|
if(isset($post['dev'])){
|
|||
|
|
$time = microtime(true) - $start;
|
|||
|
|
echo "\n".'координаты '. $time." сек.";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
//начитываем цены
|
|||
|
|
$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;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$time = microtime(true) - $start;
|
|||
|
|
if(isset($post['dev'])){
|
|||
|
|
$time = microtime(true) - $start;
|
|||
|
|
echo "\n".'цены '. $time." сек.";
|
|||
|
|
}
|
|||
|
|
if($post['view'] != 'table'){
|
|||
|
|
//начитываем данные воронки для объектов
|
|||
|
|
$objReqFunnelArray = [];
|
|||
|
|
$sqlReqFunnel = "SELECT id, funnel_id, stage, object_id FROM requisitions WHERE object_id in (" . implode(', ', $ids) .") AND (type_id = 2 or type_id in (SELECT id FROM requisitions_type WHERE heir = 2 AND agency_id = {$agency_id})) AND deleted = 0 AND cancel = 0";
|
|||
|
|
$qReqFunnel = mysql_query($sqlReqFunnel);
|
|||
|
|
|
|||
|
|
if(mysql_num_rows($qReqFunnel) > 0){
|
|||
|
|
while ($objReqFunnel = mysql_fetch_assoc($qReqFunnel)) {
|
|||
|
|
$objReqFunnelArray[] = $objReqFunnel;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$time = microtime(true) - $start;
|
|||
|
|
if(isset($post['dev'])){
|
|||
|
|
$time = microtime(true) - $start;
|
|||
|
|
echo "\n".'воронка '. $time." сек.";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//начитываем кол-во заявок для объектов
|
|||
|
|
$objRequisitionsArray = [];
|
|||
|
|
$objRequisitionsArrayTable = [];
|
|||
|
|
$sqlRequisitions = "SELECT count(id) as cnt, object_id FROM requisitions WHERE (type_id = 4 or type_id in (SELECT id FROM requisitions_type WHERE heir = 4 AND agency_id = {$agency_id})) 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)) {
|
|||
|
|
$objRequisitionsArrayTable[$objRequisitions['object_id']] = $objRequisitions['cnt'];
|
|||
|
|
$objRequisitionsArray[] = $objRequisitions;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if(isset($post['dev'])){
|
|||
|
|
$time = microtime(true) - $start;
|
|||
|
|
echo "\n".'заявки '. $time." сек.";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if($post['view'] != 'table'){
|
|||
|
|
//начитываем состояния выписок по объектам
|
|||
|
|
$objDischRequestArray = [];
|
|||
|
|
$availableRequests = $currentUser->egrn_request_count;
|
|||
|
|
if (empty($availableRequests) || $availableRequests == 0) {
|
|||
|
|
$availableRequests = $currentUser->agencyEgrnRequestCount;
|
|||
|
|
}
|
|||
|
|
if ($availableRequests > 0) {
|
|||
|
|
$sqlCountDisch = "SELECT DISTINCT state, object_id FROM discharge_object_request where object_id in (" . implode(", ", $ids) .") GROUP BY object_id";
|
|||
|
|
$rezCountDisch = mysql_query($sqlCountDisch);
|
|||
|
|
|
|||
|
|
if (mysql_num_rows($rezCountDisch) > 0) {
|
|||
|
|
while ($objDischRequest = mysql_fetch_assoc($rezCountDisch)) {
|
|||
|
|
$objDischRequestArray[] = $objDischRequest;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if(isset($post['dev'])){
|
|||
|
|
$time = microtime(true) - $start;
|
|||
|
|
echo "\n".'выписки '. $time." сек.";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
//начитываем статистику по объектам
|
|||
|
|
$objPublish = array();
|
|||
|
|
$objStatsArray = [];
|
|||
|
|
$objPablichDays = array();
|
|||
|
|
$sqlStatAll = "SELECT object_id, destination, publish_start_date, publish_end_date, days_count FROM object_publish_statistic WHERE object_id in (" . implode(", ", $ids) .") AND unpublish_user_id IS NULL AND advertising_package_object_publish_id IS NULL AND zipal_objects_id IS NULL AND on_moderation = 0";
|
|||
|
|
$qStats = mysql_query($sqlStatAll);
|
|||
|
|
|
|||
|
|
if(mysql_num_rows($qStats) > 0){
|
|||
|
|
while ($objStats = mysql_fetch_assoc($qStats)) {
|
|||
|
|
$objPublish[$objStats['destination']][] = (int)$objStats['object_id'];
|
|||
|
|
$objStatsArray[] = $objStats;
|
|||
|
|
$objPablichDays[$objStats['object_id']][$objStats['destination']] = $objStats['days_count'] . " дней";
|
|||
|
|
if($objStats['days_count'] == 5000){
|
|||
|
|
$objPablichDays[$objStats['object_id']][$objStats['destination']] = " без срока";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
if(isset($post['dev'])){
|
|||
|
|
$time = microtime(true) - $start;
|
|||
|
|
echo "\n".'стата '. $time." сек.";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$objRemoveStatsArray = [];
|
|||
|
|
$objRemovePablichDays = array();
|
|||
|
|
$sqlRemoveStatAll = "SELECT object_id, destination, publish_start_date, publish_end_date, days_count, unpublish_user_id, updated_at FROM object_publish_statistic WHERE object_id in (" . implode(", ", $ids) .") AND unpublish_user_id IS NOT NULL AND on_moderation = 0";
|
|||
|
|
$qRemoveStats = mysql_query($sqlRemoveStatAll);
|
|||
|
|
|
|||
|
|
if(mysql_num_rows($qRemoveStats) > 0){
|
|||
|
|
while ($objRemoveStats = mysql_fetch_assoc($qRemoveStats)) {
|
|||
|
|
if(!in_array($objRemoveStats['object_id'], $objPublish[$objRemoveStats['destination']]))
|
|||
|
|
$objRemoveStatsArray[$objRemoveStats['object_id']][$objRemoveStats['destination']] = $objRemoveStats;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//начитываем статистику по объектам в пакетах
|
|||
|
|
$objPackStatsArray = [];
|
|||
|
|
$sqlPackStats = "SELECT published.days AS days, published.publish_date AS publish_date, packs.name AS package, published.object_id as object_id
|
|||
|
|
FROM advertising_package_object_publish published
|
|||
|
|
JOIN advertising_package packs ON packs.id=published.advertising_package_id
|
|||
|
|
WHERE published.active=1 AND published.object_id in (" . implode(", ", $ids) .")";
|
|||
|
|
$qackStats = mysql_query($sqlPackStats);
|
|||
|
|
|
|||
|
|
if(mysql_num_rows($qackStats) > 0){
|
|||
|
|
while ($objPackStats = mysql_fetch_assoc($qackStats)) {
|
|||
|
|
$objPackStatsArray[] = $objPackStats;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(isset($post['dev'])){
|
|||
|
|
$time = microtime(true) - $start;
|
|||
|
|
echo "\n".'стата 2 '. $time." сек.";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//начитываем контракты
|
|||
|
|
$objContractsArray = [];
|
|||
|
|
$sqlContracts = "SELECT * FROM contracts_object WHERE object_id in (" . implode(", ", $ids) .")";
|
|||
|
|
$qContracts = mysql_query($sqlContracts);
|
|||
|
|
while($r_c = mysql_fetch_assoc($qContracts)) {
|
|||
|
|
$objContractsArray[] = $r_c;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
if(isset($post['dev'])){
|
|||
|
|
$time = microtime(true) - $start;
|
|||
|
|
echo "\n".'контракты '. $time." сек.";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//комплексы
|
|||
|
|
$objComplexesArray = [];
|
|||
|
|
$sqlComplex = "SELECT *, (SELECT name FROM complex_list WHERE id=co.complex_id) as complex_name FROM complex_objects as co WHERE object_id in (" . implode(", ", $ids) .")";
|
|||
|
|
$qComplex = mysql_query($sqlComplex);
|
|||
|
|
while($rComp = mysql_fetch_assoc($qComplex)) {
|
|||
|
|
$objComplexesArray[] = $rComp;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(isset($post['dev'])){
|
|||
|
|
$time = microtime(true) - $start;
|
|||
|
|
echo "\n".'комплексы '. $time." сек.";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//файлы клиентов
|
|||
|
|
$objClFilesArray = [];
|
|||
|
|
$sqlFiles = "SELECT id FROM clients_files WHERE object_id in (" . implode(", ", $ids) .") AND event_id > 0";
|
|||
|
|
$qFiles = mysql_query($sqlFiles);
|
|||
|
|
while($rFile = mysql_fetch_assoc($qFiles)) {
|
|||
|
|
$objClFilesArray[] = $rFile;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(isset($post['dev'])){
|
|||
|
|
$time = microtime(true) - $start;
|
|||
|
|
echo "\n".'файлы '. $time." сек.";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//метро
|
|||
|
|
$objMetroArray = [];
|
|||
|
|
$objMetroArrayTable = array();
|
|||
|
|
$sqlMetro = "SELECT metro.metro, sp_metro.id_obj FROM metro, sp_metro WHERE sp_metro.id_metro = metro.id AND sp_metro.id_obj IN (" . implode(", ", $ids) .")";
|
|||
|
|
$resultMetro = mysql_query($sqlMetro);
|
|||
|
|
while($metro = mysql_fetch_assoc($resultMetro)) {
|
|||
|
|
$objMetroArray[] = $metro;
|
|||
|
|
if(!isset($objMetroArrayTable[$metro['id_obj']])) $objMetroArrayTable[$metro['id_obj']] = array();
|
|||
|
|
$objMetroArrayTable[$metro['id_obj']][] = $metro;
|
|||
|
|
}
|
|||
|
|
if(isset($post['dev'])){
|
|||
|
|
$time = microtime(true) - $start;
|
|||
|
|
echo "\n".'метро '. $time." сек.";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if($post['view'] != 'table'){
|
|||
|
|
|
|||
|
|
|
|||
|
|
//начитка комментов
|
|||
|
|
if (empty($notes_bd_usl)) {
|
|||
|
|
$notes_bd_usl = ' true';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$objCntNotesArray = [];
|
|||
|
|
$sqlCntNotes = "SELECT id, object_id FROM object_notes WHERE object_id in (" . implode(", ", $ids) .")";
|
|||
|
|
$resultCntNotes = mysql_query($sqlCntNotes);
|
|||
|
|
while($note = mysql_fetch_assoc($resultCntNotes)) {
|
|||
|
|
$objCntNotesArray[] = $note;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(isset($post['dev'])){
|
|||
|
|
$time = microtime(true) - $start;
|
|||
|
|
echo "\n".'кмменты '. $time." сек.";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//начитка истории цен
|
|||
|
|
$objPriceHistoryArray = [];
|
|||
|
|
$sqlPriceHistoryAll = "SELECT date_change_price, price, price_ku, object_id, final_sale_price FROM objects_price_history WHERE object_id IN (" . implode(", ", $ids) .")";
|
|||
|
|
$rezPriceHistoryAll = mysql_query($sqlPriceHistoryAll);
|
|||
|
|
while($priceHist = mysql_fetch_assoc($rezPriceHistoryAll)) {
|
|||
|
|
$objPriceHistoryArray[] = $priceHist;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(isset($post['dev'])){
|
|||
|
|
$time = microtime(true) - $start;
|
|||
|
|
echo "\n".'цены '. $time." сек.";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//начитка модерации
|
|||
|
|
$is_advert_moderation = false;
|
|||
|
|
$can_moderation_user = true;
|
|||
|
|
$object_moderation = array();
|
|||
|
|
//Предмодерация рекламы по объектам.
|
|||
|
|
$sql_moderation = "SELECT * FROM advert_moderation_agency WHERE agency_id = {$agency_id}";
|
|||
|
|
|
|||
|
|
$q_moderation = mysql_query($sql_moderation);
|
|||
|
|
if(mysql_num_rows($q_moderation) > 0){
|
|||
|
|
$is_advert_moderation = true;
|
|||
|
|
$moderationClass = new ModerationAdvert();
|
|||
|
|
|
|||
|
|
|
|||
|
|
$object_moderation = $moderationClass->get_object_moderation($ids);
|
|||
|
|
|
|||
|
|
if($currentUser->show_all_objects_page == 0){
|
|||
|
|
$can_moderation_user = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if(isset($post['dev'])){
|
|||
|
|
|
|||
|
|
$time = microtime(true) - $start;
|
|||
|
|
echo "\n".'модерация '. $time." сек.";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//тут нам нужен реальный пользователь, чтобы знать его логины и пароли
|
|||
|
|
$user = new User();
|
|||
|
|
$user->get($_SESSION['id']);
|
|||
|
|
$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(isset($post['dev'])){
|
|||
|
|
$time = microtime(true) - $start;
|
|||
|
|
echo "\n".'теги все '. $time." сек.";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
if($post['view'] == 'table'){
|
|||
|
|
//Начитываем размещение рекламы
|
|||
|
|
$objPromoAdsArray = array();
|
|||
|
|
$sqlPromo = "SELECT * FROM ads_promo WHERE object_id in (" . implode(", ", $ids) .")";
|
|||
|
|
$qPromo = mysql_query($sqlPromo);
|
|||
|
|
while($rPromo = mysql_fetch_assoc($qPromo)){
|
|||
|
|
$objPromoAdsArray[$rPromo['object_id']] = $rPromo;
|
|||
|
|
}
|
|||
|
|
$rayonObjectNameArrayTable = array();
|
|||
|
|
$sql_rayon = "SELECT id, rayon FROM rayon WHERE id in (".implode(',', $rayonIds).")";
|
|||
|
|
$q_rayon = mysql_query($sql_rayon);
|
|||
|
|
while($r_rayon = mysql_fetch_assoc($q_rayon)){
|
|||
|
|
$rayonObjectNameArrayTable[$r_rayon['id']] = $r_rayon['rayon'];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$objDatesAndPriceInPeriod = array();
|
|||
|
|
$sqlDatesAndPriceInPeriod = "SELECT object_id, publish_start_date, publish_end_date, price, created_at, days_count FROM object_publish_statistic WHERE on_moderation = 0 AND object_id in (" . implode(", ", $ids) .") order by object_id";
|
|||
|
|
$rezDatesAndSumInPeriod = mysql_query($sqlDatesAndPriceInPeriod);
|
|||
|
|
while($publishDates = mysql_fetch_assoc($rezDatesAndSumInPeriod)){
|
|||
|
|
if(!isset($objDatesAndPriceInPeriod[$publishDates['object_id']])) $objDatesAndPriceInPeriod[$publishDates['object_id']] = array();
|
|||
|
|
//$objDatesAndPriceInPeriod[$publishDates['object_id']][] = $publishDates;
|
|||
|
|
if (!isset($objDatesAndPriceInPeriod[$publishDates['object_id']]['minDate'])) {
|
|||
|
|
$objDatesAndPriceInPeriod[$publishDates['object_id']]['minDate'] = $publishDates['publish_start_date'];
|
|||
|
|
} else {
|
|||
|
|
if (strtotime($objDatesAndPriceInPeriod[$publishDates['object_id']]['minDate']) > strtotime($publishDates['publish_start_date'])) {
|
|||
|
|
$objDatesAndPriceInPeriod[$publishDates['object_id']]['minDate'] = $publishDates['publish_start_date'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if ($publishDates['days_count'] != 5000) {
|
|||
|
|
if (!$objDatesAndPriceInPeriod[$publishDates['object_id']]['maxDate']) {
|
|||
|
|
$objDatesAndPriceInPeriod[$publishDates['object_id']]['maxDate'] = $publishDates['publish_end_date'];
|
|||
|
|
} else {
|
|||
|
|
if (strtotime($objDatesAndPriceInPeriod[$publishDates['object_id']]['maxDate']) < strtotime($publishDates['publish_end_date'])) {
|
|||
|
|
$objDatesAndPriceInPeriod[$publishDates['object_id']]['maxDate'] = $publishDates['publish_end_date'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
$objDatesAndPriceInPeriod[$publishDates['object_id']]['sumPrice'] = $objDatesAndPriceInPeriod[$publishDates['object_id']]['sumPrice'] + $publishDates['price'];
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(isset($post['dev'])){
|
|||
|
|
$time = microtime(true) - $start;
|
|||
|
|
echo "\n".'реклама '. $time." сек.";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$clientObjIdsSql = array();
|
|||
|
|
$clientData = [];
|
|||
|
|
$sql_cl_obj = "SELECT co.client_id, co.object_id, c.fio, c.email, c.phone FROM client_objects as co
|
|||
|
|
LEFT JOIN clients as c on co.client_id = c.id WHERE object_id in (" . implode(", ", $ids) .")";
|
|||
|
|
|
|||
|
|
$q_cl_obj = mysql_query($sql_cl_obj);
|
|||
|
|
while($r_cl_obj = mysql_fetch_assoc($q_cl_obj)){
|
|||
|
|
if(!isset($clientData[$r_cl_obj['object_id']])) $clientData[$r_cl_obj['object_id']] = array();
|
|||
|
|
|
|||
|
|
$clientItem = array(
|
|||
|
|
'fio' => $r_cl_obj['fio'],
|
|||
|
|
'phone' => $r_cl_obj['phone'],
|
|||
|
|
'id' => $r_cl_obj['client_id'],
|
|||
|
|
);
|
|||
|
|
mask_client_contacts_inplace($clientItem);
|
|||
|
|
$clientData[$r_cl_obj['object_id']][] = $clientItem;
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
if(isset($post['dev'])){
|
|||
|
|
$time = microtime(true) - $start;
|
|||
|
|
echo "\n".'собственник '. $time." сек.";
|
|||
|
|
}
|
|||
|
|
$presentationsCounts = [];
|
|||
|
|
$sqlPresentation = "SELECT count(id) as total, id_object FROM sended_pdf WHERE id_object in (" . implode(", ", $ids) .") group by id_object";
|
|||
|
|
$rezPresentation = mysql_query($sqlPresentation);
|
|||
|
|
while($r_presentation = mysql_fetch_assoc($rezPresentation)){
|
|||
|
|
$presentationsCounts[$r_presentation['id_object']] = (int)$r_presentation['total'];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$meetCounts = [];
|
|||
|
|
$sqlMeet = "SELECT count(id) as total, object_id FROM user_object_events WHERE object_id in (" . implode(", ", $ids) .") and `type` = 'show' and calendar_view = 1
|
|||
|
|
and schedule_date is not null group by object_id";
|
|||
|
|
|
|||
|
|
$rezMeet = mysql_query($sqlMeet);
|
|||
|
|
while($meetCount = mysql_fetch_assoc($rezMeet)){
|
|||
|
|
$meetCounts[$meetCount['object_id']] = (int)$meetCount['total'];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//Договоры
|
|||
|
|
$contracts = [];
|
|||
|
|
$sql_contracts = "SELECT *, (SELECT type FROM contract_types WHERE id=contracts_object.type) as type_name FROM `contracts_object` WHERE object_id in (".implode(',', $ids).")";
|
|||
|
|
$q_contract = mysql_query($sql_contracts);
|
|||
|
|
while($contract = mysql_fetch_assoc($q_contract)){
|
|||
|
|
if(!isset($contracts[$contract['object_id']])){
|
|||
|
|
$contracts[$contract['object_id']] = Array('types'=>'', 'numbers'=>'', 'dates'=>'');
|
|||
|
|
}
|
|||
|
|
if($contracts[$contract['object_id']]['types'] != '') $contracts[$contract['object_id']]['types'] .= '; ';
|
|||
|
|
if($contracts[$contract['object_id']]['numbers'] != '') $contracts[$contract['object_id']]['numbers'] .= '; ';
|
|||
|
|
if($contracts[$contract['object_id']]['dates'] != '') $contracts[$contract['object_id']]['dates'] .= '; ';
|
|||
|
|
$contracts[$contract['object_id']]['types'] .= $contract['type_name'];
|
|||
|
|
$contracts[$contract['object_id']]['numbers'] .= '№'.$contract['number'];
|
|||
|
|
$contracts[$contract['object_id']]['dates'] .= date('d.m.Y',$contract['date_start']).' - '.date('d.m.Y',$contract['date_end']);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
// LEFT JOIN rayon rayon on objects.rayon = rayon.id
|
|||
|
|
|
|||
|
|
$objectsFound = [];
|
|||
|
|
if($post['view'] == 'table'){
|
|||
|
|
foreach($objSphinx as $obj){
|
|||
|
|
if (isset($rezPhotoArray[$obj["id"]])) {
|
|||
|
|
foreach ($rezPhotoArray[$obj["id"]] as $key => $photo) {
|
|||
|
|
$obj[$key] = $photo;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (isset($rezActivityTableArray[$obj["id"]])) {
|
|||
|
|
$obj['activities'] = $rezActivityTableArray[$obj["id"]];
|
|||
|
|
} else {
|
|||
|
|
$obj['activities'] = null;
|
|||
|
|
}
|
|||
|
|
if(isset($rayonObjectNameArrayTable[$obj['rayon_id']])){
|
|||
|
|
$obj['rayon'] = $rayonObjectNameArrayTable[$obj['rayon_id']];
|
|||
|
|
}
|
|||
|
|
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'];
|
|||
|
|
}
|
|||
|
|
if (!is_null($objPrice['currency'])) {
|
|||
|
|
$obj['currency'] = $objPrice['currency'];
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$objectsFound[] = $obj;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
$time = microtime(true) - $start;
|
|||
|
|
if(isset($post['dev'])){
|
|||
|
|
echo 'начитка 1 '. $time." сек.";
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
while ($obj = mysql_fetch_assoc($rez)) {
|
|||
|
|
|
|||
|
|
// Если дата пришла как число (из Sphinx) или пустая, принудительно форматируем её
|
|||
|
|
// Это страховка, чтобы на экране всегда была строка вида "05.05.2026 18:37"
|
|||
|
|
if (!empty($obj['date_add']) && is_numeric($obj['date_add'])) {
|
|||
|
|
$obj['date_add'] = date('d.m.Y H:i', $obj['date_add']);
|
|||
|
|
}
|
|||
|
|
// Если дата пришла как 0 (пустая), можно поставить прочерк или текущую дату
|
|||
|
|
if (empty($obj['date_add']) || $obj['date_add'] == '0000-00-00 00:00:00') {
|
|||
|
|
$obj['date_add'] = date('d.m.Y H:i'); // или '-', если нужно
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (isset($rezAddInfoArray[$obj["id"]])) {
|
|||
|
|
$objAddInfo = $rezAddInfoArray[$obj["id"]];
|
|||
|
|
$obj['apartments'] = $objAddInfo['apartments'];
|
|||
|
|
$obj['video_url'] = $objAddInfo['video_url'];
|
|||
|
|
$obj['balcony'] = $objAddInfo['balcony'];
|
|||
|
|
$obj['loggias'] = $objAddInfo['loggias'];
|
|||
|
|
$obj['separate_wcs'] = $objAddInfo['separate_wcs'];
|
|||
|
|
$obj['combined_wcs'] = $objAddInfo['combined_wcs'];
|
|||
|
|
$obj['passenger_lifts'] = $objAddInfo['passenger_lifts'];
|
|||
|
|
$obj['cargo_lifts'] = $objAddInfo['cargo_lifts'];
|
|||
|
|
$obj['window_view'] = $objAddInfo['window_view'];
|
|||
|
|
$obj['renovation'] = $objAddInfo['renovation'];
|
|||
|
|
$obj['ceiling_height'] = $objAddInfo['ceiling_height'];
|
|||
|
|
$obj['vat_type_id'] = $objAddInfo['vat_type_id'];
|
|||
|
|
$obj['house_category'] = $objAddInfo['house_category'];
|
|||
|
|
$obj['commerc_land_category_name'] = $objAddInfo['commerc_land_category_name'];
|
|||
|
|
$obj['commission_agency'] = $objAddInfo['commission_agency'];
|
|||
|
|
$obj['commission_agency_type'] = $objAddInfo['commission_agency_type'];
|
|||
|
|
$obj['flat_number'] = $objAddInfo['flat_number'];
|
|||
|
|
$obj['building_area'] = $objAddInfo['building_area'];
|
|||
|
|
} else {
|
|||
|
|
$obj['apartments'] = 0;
|
|||
|
|
$obj['video_url'] = '';
|
|||
|
|
$obj['balcony'] = null;
|
|||
|
|
$obj['loggias'] = null;
|
|||
|
|
$obj['separate_wcs'] = null;
|
|||
|
|
$obj['combined_wcs'] = null;
|
|||
|
|
$obj['passenger_lifts'] = null;
|
|||
|
|
$obj['cargo_lifts'] = null;
|
|||
|
|
$obj['window_view'] = 0;
|
|||
|
|
$obj['renovation'] = null;
|
|||
|
|
$obj['ceiling_height'] = null;
|
|||
|
|
$obj['vat_type_id'] = 0;
|
|||
|
|
$obj['house_category'] = 0;
|
|||
|
|
$obj['commerc_land_category_name'] = null;
|
|||
|
|
$obj['commission_agency'] = 0;
|
|||
|
|
$obj['commission_agency_type'] = null;
|
|||
|
|
$obj['flat_number'] = null;
|
|||
|
|
$obj['building_area'] = null;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (isset($rezActivityArray[$obj["id"]])) {
|
|||
|
|
$obj['activities'] = $rezActivityArray[$obj["id"]];
|
|||
|
|
} else {
|
|||
|
|
$obj['activities'] = null;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (isset($objAdsErrors[$obj['id']])) {
|
|||
|
|
$obj['ads_errors'] = $objAdsErrors[$obj['id']];
|
|||
|
|
} else {
|
|||
|
|
$obj['ads_errors'] = null;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (isset($objAdsSended[$obj['id']])) {
|
|||
|
|
$obj['ads_send'] = $objAdsSended[$obj['id']];
|
|||
|
|
} else {
|
|||
|
|
$obj['ads_send'] = null;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (isset($rezPhotoArray[$obj["id"]])) {
|
|||
|
|
foreach ($rezPhotoArray[$obj["id"]] as $key => $photo) {
|
|||
|
|
$obj[$key] = $photo;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
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'];
|
|||
|
|
}
|
|||
|
|
if (!is_null($objPrice['currency'])) {
|
|||
|
|
$obj['currency'] = $objPrice['currency'];
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (!isset($post['view']) || (isset($post['view']) && $post['view'] == 'list')) {
|
|||
|
|
$gmtmsk = get_time_zone_user();
|
|||
|
|
|
|||
|
|
|
|||
|
|
$time_zone = '';
|
|||
|
|
|
|||
|
|
if($gmtmsk >= 0){
|
|||
|
|
$time_zone = '+'.$gmtmsk.' hour';
|
|||
|
|
} else {
|
|||
|
|
$time_zone = '-'.$gmtmsk.' hour';
|
|||
|
|
}
|
|||
|
|
if ($post['compObj'] == '1') {
|
|||
|
|
$isCompanyObjects = true;
|
|||
|
|
}
|
|||
|
|
include($_SERVER['DOCUMENT_ROOT'] . "/templates/system__object_new.php");
|
|||
|
|
} else {
|
|||
|
|
|
|||
|
|
/* 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'];
|
|||
|
|
};*/
|
|||
|
|
$time = microtime(true) - $start;
|
|||
|
|
if(isset($post['dev'])){
|
|||
|
|
echo 'кл '. $time." сек.";
|
|||
|
|
}
|
|||
|
|
$objectsFound[] = $obj;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// if ($_COOKIE['debug_spd']) { echo '<script>console.log(`ajax/getObjectsView.php:1372 '.microtime(true).'`)</script>'; }
|
|||
|
|
|
|||
|
|
if (isset($objectsFound) && !empty($objectsFound)) {
|
|||
|
|
//$clientData = [];
|
|||
|
|
//$clientCountData = [];
|
|||
|
|
$r_check_permissions = $user->checkMenuPermissions();
|
|||
|
|
/* if (isset($clientObjIdsSql) && !empty($clientObjIdsSql)) {
|
|||
|
|
$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);
|
|||
|
|
foreach ($objIdsTmp as $objIdTmp) {
|
|||
|
|
if (!isset($clientData[$objIdTmp])) {
|
|||
|
|
$clientData[$objIdTmp] = [];
|
|||
|
|
}
|
|||
|
|
$clientData[$objIdTmp][] = [
|
|||
|
|
'fio' => $client['fio'],
|
|||
|
|
'phone' => $client['phone'],
|
|||
|
|
'id' => $client['id'],
|
|||
|
|
];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if ($_COOKIE['debug_spd']) { echo '<script>console.log(`ajax/getObjectsView.php:1398 '.microtime(true).'`)</script>'; }
|
|||
|
|
|
|||
|
|
}*/
|
|||
|
|
foreach ($objectsFound as $obj) {
|
|||
|
|
|
|||
|
|
// if($post['is_custom'] == 0) {
|
|||
|
|
include($_SERVER['DOCUMENT_ROOT'] . "/templates/system__object_table.php");
|
|||
|
|
// }//
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
$time = microtime(true) - $start;
|
|||
|
|
if(isset($post['dev'])){
|
|||
|
|
echo 'начитка '. $time." сек.";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (isset($post['view']) && $post['view'] == 'table') {
|
|||
|
|
// if ($_COOKIE['debug_spd']) { echo '<script>console.log(`ajax/getObjectsView.php:1370 '.microtime(true).'`)</script>'; }
|
|||
|
|
include($_SERVER['DOCUMENT_ROOT'] . "/templates/system__object_table_footer.php");
|
|||
|
|
|
|||
|
|
if(isset($post['dev'])){
|
|||
|
|
echo "\n".'футер '. $time." сек.";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if($post['view'] != 'table'){ ?>
|
|||
|
|
<div class="f-system_pagination">
|
|||
|
|
<ul class="pagination" style="display: inline-flex;">
|
|||
|
|
<?php
|
|||
|
|
if ($all_pages > 1) {
|
|||
|
|
num_of_pages($page, $all_pages, $str_url_add);
|
|||
|
|
}
|
|||
|
|
?>
|
|||
|
|
<div class="clear"></div>
|
|||
|
|
</ul>
|
|||
|
|
<?php
|
|||
|
|
if ($all_pages > 1) {
|
|||
|
|
echo '<span style="padding-left: 15px; float: none; border: none;" class="control-group kol_find">перейти на <input type="number" maxlength="6" class="number text small-input no-mrg-left" placeholder="№ стр." onkeypress="goToObjectsPage(event, this)"/></span>';
|
|||
|
|
}
|
|||
|
|
?>
|
|||
|
|
</div>
|
|||
|
|
<?php
|
|||
|
|
}
|
|||
|
|
$time = microtime(true) - $start;
|
|||
|
|
if(isset($post['dev'])){
|
|||
|
|
echo 'начитка 2 '. $time." сек.";
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
|
|||
|
|
?>
|
|||
|
|
<div class="empty-block">
|
|||
|
|
<h1><i class="ti-na"></i></h1>
|
|||
|
|
<h2>Объектов не найдено</h2>
|
|||
|
|
</div>
|
|||
|
|
<?php }?>
|
|||
|
|
<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>
|
|||
|
|
<?php
|
|||
|
|
}
|
|||
|
|
if ($_COOKIE['debug_spd']) { echo '<script>console.log(`ajax/getObjectsView.php:1418 '.microtime(true).'`)</script>'; }
|
|||
|
|
|
|||
|
|
?>
|