1242 lines
53 KiB
PHP
1242 lines
53 KiB
PHP
|
|
<?php
|
|||
|
|
|
|||
|
|
$start = microtime(true);
|
|||
|
|
|
|||
|
|
require_once($_SERVER['DOCUMENT_ROOT'] . "/config.php");
|
|||
|
|
require_once($_SERVER['DOCUMENT_ROOT'].'/vendor/autoload.php');
|
|||
|
|
|
|||
|
|
$date = date('d.m.Y H-i-s');
|
|||
|
|
|
|||
|
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
|||
|
|
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
|||
|
|
|
|||
|
|
$spreadsheet = new Spreadsheet();
|
|||
|
|
$sheet = $spreadsheet->getActiveSheet();
|
|||
|
|
|
|||
|
|
$post = clearInputData($_POST);
|
|||
|
|
|
|||
|
|
$usersArr = json_decode($_POST['responsible'], true);
|
|||
|
|
|
|||
|
|
$one_page_size = 10;
|
|||
|
|
|
|||
|
|
/*$page = $post['page'];
|
|||
|
|
|
|||
|
|
if(!isset($page) || $page < 1) {
|
|||
|
|
$page = 1;
|
|||
|
|
}*/
|
|||
|
|
|
|||
|
|
//$limit = ' limit '.(($page-1) * $one_page_size) . ', ' . $one_page_size;
|
|||
|
|
|
|||
|
|
$cl = new Clients();
|
|||
|
|
|
|||
|
|
//список тех, кто входит в статистику.
|
|||
|
|
$usersId = $cl->getUsersFilter($usersArr, $post['user_id'], $post['users_admin']);
|
|||
|
|
$user_id = $post['user_id'];
|
|||
|
|
|
|||
|
|
$usersIdReal = array();
|
|||
|
|
|
|||
|
|
//пользователь, по которому смотрим объекты
|
|||
|
|
$userId = $post['userId'];
|
|||
|
|
//тип для вывода списка объектов - обозначнеие столбца из таблицы
|
|||
|
|
$type = $post['type'];
|
|||
|
|
|
|||
|
|
$user = mysql_fetch_assoc(mysql_query("SELECT agency, manager, agency_name, last_name, first_name, middle_name, id_manager FROM users WHERE id=" . $userId));
|
|||
|
|
|
|||
|
|
$arrIdAddUsers = $arrIdWhoWork = array();
|
|||
|
|
|
|||
|
|
//если смотрим статистику по агентству, то смотрим по всем, кто в списке
|
|||
|
|
if ($user['agency']) {
|
|||
|
|
foreach ($usersId as $usrId) {
|
|||
|
|
$arrIdWhoWork[] = "who_work = $usrId";
|
|||
|
|
$arrIdAddUsers[] = $usrId;
|
|||
|
|
}
|
|||
|
|
$usersIdReal = $usersId;
|
|||
|
|
} elseif ($user['manager']) {
|
|||
|
|
|
|||
|
|
$arrIdWhoWork[] = "who_work = $userId";
|
|||
|
|
$arrIdAddUsers[] = $userId;
|
|||
|
|
$usersIdReal[] = $userId;
|
|||
|
|
|
|||
|
|
$usersResult = mysql_query("SELECT id, manager FROM users WHERE id_manager=" . $userId);
|
|||
|
|
|
|||
|
|
while ($usr = mysql_fetch_assoc($usersResult)) {
|
|||
|
|
if (in_array($usr['id'], $usersId)) {
|
|||
|
|
$arrIdWhoWork[] = "who_work = $usr[id]";
|
|||
|
|
$arrIdAddUsers[] = $usr['id'];
|
|||
|
|
$usersIdReal[] = $usr['id'];
|
|||
|
|
}
|
|||
|
|
if($usr['manager'] > 0){
|
|||
|
|
$rez004 = mysql_query("SELECT id FROM users WHERE id_manager=$usr[id]");
|
|||
|
|
while ($mm02 = mysql_fetch_assoc($rez004)) {
|
|||
|
|
if(!in_array((int)$mm02['id'], $arrIdAddUsers)){
|
|||
|
|
$arrIdWhoWork[] = "who_work = $mm02[id]";
|
|||
|
|
$arrIdAddUsers[] = $mm02['id'];
|
|||
|
|
$usersIdReal[] = $mm02['id'];
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
} else {
|
|||
|
|
$arrIdWhoWork[] = "who_work = $userId";
|
|||
|
|
$arrIdAddUsers[] = $userId;
|
|||
|
|
$usersIdReal[] = $userId;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$bd_usl_addUsers = " id_add_user in (" . implode(",", $arrIdAddUsers) . ")";
|
|||
|
|
$bd_usl_whoWork = " AND (" . implode(" OR ", $arrIdWhoWork) . ")";
|
|||
|
|
|
|||
|
|
$period = 'all';
|
|||
|
|
$bd_piriod = '';
|
|||
|
|
$bd_piriod_objects = '';
|
|||
|
|
|
|||
|
|
if (isset($post['period'])) {
|
|||
|
|
$period = $post['period'];
|
|||
|
|
if ($period == 'dates') {
|
|||
|
|
/* $onDate = date('Y-m-d 00:00:00', strtotime($post['onDate']));
|
|||
|
|
if (empty($onDate)) {
|
|||
|
|
$onDate = '1970-01-01 00:00:00';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!empty($post['offDate'])) {
|
|||
|
|
$offDate = date('Y-m-d 23:59:59', strtotime($_POST['offDate']));
|
|||
|
|
} else {
|
|||
|
|
$offDate = date('Y-m-d 23:59:59');
|
|||
|
|
}
|
|||
|
|
$bd_piriod .= " AND `date_add` between '{$onDate}' AND '{$offDate}'";
|
|||
|
|
$bd_piriod_objects .= " AND `date_really_add` between '{$onDate}' AND '{$offDate}'";*/
|
|||
|
|
$_SESSION['on_date'] = $post['onDate'];
|
|||
|
|
$_SESSION['off_date'] = $post['offDate'];
|
|||
|
|
} else {
|
|||
|
|
unset($_SESSION['on_date']);
|
|||
|
|
unset($_SESSION['off_date']);
|
|||
|
|
/* $arrPeriod = ['today' => '-0 day', 'week' => '-6 day', 'month' => '-30 day', 'quarter' => '-120 day', 'year' => '-365'];
|
|||
|
|
$days = date('Y-m-d', strtotime($arrPeriod[$post['period']]));
|
|||
|
|
$bd_piriod .= " AND `date_add` > '{$days}'";
|
|||
|
|
$bd_piriod_objects .= " AND `date_really_add` > '{$days}'";*/
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$lastDay = '';
|
|||
|
|
$startDate = '1970-01-01 00:00:00';
|
|||
|
|
$endDate = '3000-12-31 23:59:59';
|
|||
|
|
$whereTasks = " and DATE_FORMAT(schedule_date, '%Y-%m-%d %H:%i:%s') between '1970-01-01 00:00:00' AND '3000-12-31 23:59:59'";
|
|||
|
|
|
|||
|
|
/*switch ($period) {
|
|||
|
|
case 'month': {
|
|||
|
|
$totalDays = cal_days_in_month(CAL_GREGORIAN, (int)date('m'), date('Y'));
|
|||
|
|
$lastDay = $totalDays;
|
|||
|
|
$startDate = date('Y') . "-" . date('m') . "-01 00:00:00";
|
|||
|
|
$endDate = date('Y') . "-" . date('m') . "-" . $lastDay . " 23:59:59";
|
|||
|
|
$whereTasks = " and DATE_FORMAT(schedule_date, '%Y-%m-%d %H:%i:%s') between '".date('Y')."-".date('m')."-01 00:00:00' AND '".date('Y')."-".date('m')."-".$lastDay." 23:59:59'";
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
case 'today':{
|
|||
|
|
$startDate = date("Y-m-d 00:00:00");
|
|||
|
|
$endDate = date("Y-m-d 23:59:59");
|
|||
|
|
$whereTasks = " and DATE_FORMAT(schedule_date, '%Y-%m-%d %H:%i:%s') between '".date("Y-m-d 00:00:00")."' AND '".date("Y-m-d 23:59:59")."'";
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
case 'quarter' : {
|
|||
|
|
$nowMonth = (int)date('m');
|
|||
|
|
if ($nowMonth < 4) {
|
|||
|
|
$startDate = date('Y') . "-01-01 00:00:00";
|
|||
|
|
$endDate = date('Y') . "-03-31 23:59:59";
|
|||
|
|
$whereTasks = " and DATE_FORMAT(schedule_date, '%Y-%m-%d %H:%i:%s') between '".date('Y')."-01-01 00:00:00' AND '".date('Y')."-03-31 23:59:59'";
|
|||
|
|
} else if ($nowMonth >= 4 && $nowMonth < 7) {
|
|||
|
|
$startDate = date('Y') . "-04-01 00:00:00";
|
|||
|
|
$endDate = date('Y') . "-06-30 23:59:59";
|
|||
|
|
$whereTasks = " and DATE_FORMAT(schedule_date, '%Y-%m-%d %H:%i:%s') between '".date('Y')."-04-01 00:00:00' AND '".date('Y')."-06-30 23:59:59'";
|
|||
|
|
} else if ($nowMonth >= 7 && $nowMonth < 10) {
|
|||
|
|
$startDate = date('Y') . "-07-01 00:00:00";
|
|||
|
|
$endDate = date('Y') . "-09-30 23:59:59";
|
|||
|
|
$whereTasks = " and DATE_FORMAT(schedule_date, '%Y-%m-%d %H:%i:%s') between '".date('Y')."-07-01 00:00:00' AND '".date('Y')."-09-30 23:59:59'";
|
|||
|
|
} else if ($nowMonth >= 10 && $nowMonth < 13) {
|
|||
|
|
$startDate = date('Y') . "-10-01 00:00:00";
|
|||
|
|
$endDate = date('Y') . "-12-31 23:59:59";
|
|||
|
|
$whereTasks = " and DATE_FORMAT(schedule_date, '%Y-%m-%d %H:%i:%s') between '".date('Y')."-10-01 00:00:00' AND '".date('Y')."-12-31 23:59:59'";
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
case 'week': {
|
|||
|
|
$startDate = date("Y-m-d 00:00:00", strtotime("monday this week"));
|
|||
|
|
$endDate = date("Y-m-d 23:59:59", strtotime("sunday this week"));
|
|||
|
|
$whereTasks = " and DATE_FORMAT(schedule_date, '%Y-%m-%d %H:%i:%s') between '".date("Y-m-d 00:00:00", strtotime("monday this week"))."' AND '".date("Y-m-d 23:59:59", strtotime("sunday this week"))."'";
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
case 'dates' : {
|
|||
|
|
$onDate = $_POST['onDate'];
|
|||
|
|
//if(empty($onDate)) $onDate = '1970-01-01 00:00:00';
|
|||
|
|
$offDate = $_POST['offDate'];
|
|||
|
|
if (empty($offDate)) {
|
|||
|
|
$offDate = date('Y-m-d 23:59:59');
|
|||
|
|
}
|
|||
|
|
$startDate = date("Y-m-d 00:00:00", strtotime($onDate));
|
|||
|
|
$endDate = date("Y-m-d 23:59:59", strtotime($offDate));
|
|||
|
|
$whereTasks = " and DATE_FORMAT(schedule_date, '%Y-%m-%d %H:%i:%s') between '".date("Y-m-d 00:00:00", strtotime($onDate))."' AND '".date("Y-m-d 23:59:59", strtotime($offDate))."'";
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
case 'year' : {
|
|||
|
|
$startDate = date('Y') . "-01-01 00:00:00";
|
|||
|
|
$endDate = date('Y') . "-12-31 23:59:59";
|
|||
|
|
$whereTasks = " and DATE_FORMAT(schedule_date, '%Y-%m-%d %H:%i:%s') between '".date('Y')."-01-01 00:00:00' AND '".date('Y')."-12-31 23:59:59'";
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$date_between = "between '" . $startDate . "' AND '" . $endDate . "'";*/
|
|||
|
|
$dates = getPeriod($period,$_POST['onDate'],$_POST['offDate']);
|
|||
|
|
$startDate = $dates['dateStart'];
|
|||
|
|
$endDate = $dates['dateEnd'];
|
|||
|
|
$date_between = "between '" . $dates['dateStart'] . "' AND '" . $dates['dateEnd'] . "'";
|
|||
|
|
$bd_piriod .= " AND `date_add` between '{$dates['dateStart']}' AND '{$dates['dateEnd']}'";
|
|||
|
|
$bd_piriod_objects .= " AND `date_really_add` between '{$dates['dateStart']}' AND '{$dates['dateEnd']}'";
|
|||
|
|
$date_between = $dates['between'];
|
|||
|
|
$whereTasks = $dates['whereTasks'];
|
|||
|
|
|
|||
|
|
$db = new MysqlPdo(hstsph, null, null, null, true, '9306');
|
|||
|
|
|
|||
|
|
$user = new User;
|
|||
|
|
$user->get($_SESSION['id']);
|
|||
|
|
$user->checkPermissions();
|
|||
|
|
|
|||
|
|
$all_pages = 0;
|
|||
|
|
|
|||
|
|
if ($post['type'] == 'added') {
|
|||
|
|
$objectIds = array();
|
|||
|
|
$total = 0;
|
|||
|
|
|
|||
|
|
$sqlS = "SELECT id FROM objects, objects_delta WHERE $bd_usl_addUsers LIMIT 1000000 OPTION max_matches=1000000";
|
|||
|
|
|
|||
|
|
$rezS = $db->query($sqlS);
|
|||
|
|
while($rS = $db->fetch_assoc($rezS)) {
|
|||
|
|
$objectIds[] = $rS['id'];
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$sqlAddedObjCount = "SELECT id FROM objects WHERE id in (".implode(',', $objectIds).") $bd_piriod_objects ORDER BY objects.id ";
|
|||
|
|
// echo $sqlAddedObjCount;
|
|||
|
|
// die();
|
|||
|
|
$objectIds = array();
|
|||
|
|
$rezAddedObjCount = mysql_query($sqlAddedObjCount);
|
|||
|
|
while($r_rezAddedObjCount = mysql_fetch_array($rezAddedObjCount)){
|
|||
|
|
$objectIds[] = $r_rezAddedObjCount[0];
|
|||
|
|
$total++;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$all_pages = ceil($total/$one_page_size);
|
|||
|
|
|
|||
|
|
$sqlAddedObj = "SELECT objects.*, rayon.rayon, DATE_FORMAT(objects.date_add,'%d.%m.%Y %H:%i') as date_add, DATE_FORMAT(objects.date_really_add,'%d.%m.%Y %H:%i') as date_really_add
|
|||
|
|
FROM objects LEFT JOIN rayon rayon on objects.rayon = rayon.id WHERE objects.id in (".implode(',', $objectIds).") ORDER BY objects.id ";
|
|||
|
|
//echo $sqlAddedObj;
|
|||
|
|
$query = mysql_query($sqlAddedObj);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($post['type'] == 'advBeforePeriod') {
|
|||
|
|
$sqlAdvBeforePeriodObjCount = "SELECT objects.id FROM objects WHERE objects.id in (SELECT DISTINCT object_id FROM object_publish_statistic WHERE on_moderation = 0 AND user_owner_id in (" . implode(', ', $usersIdReal) . ") and
|
|||
|
|
'$startDate' between publish_start_date and publish_end_date) ORDER BY objects.id ";
|
|||
|
|
$rezAdvBeforePeriodObjCount = mysql_query($sqlAdvBeforePeriodObjCount);
|
|||
|
|
$total = mysql_num_rows($rezAdvBeforePeriodObjCount);
|
|||
|
|
|
|||
|
|
$all_pages = ceil($total/$one_page_size);
|
|||
|
|
|
|||
|
|
$sqlAdvBeforePeriodObj = "SELECT objects.*,
|
|||
|
|
rayon.rayon,
|
|||
|
|
DATE_FORMAT(objects.date_add,'%d.%m.%Y %H:%i') AS date_add,
|
|||
|
|
DATE_FORMAT(objects.date_really_add,'%d.%m.%Y %H:%i') AS date_really_add
|
|||
|
|
FROM objects
|
|||
|
|
LEFT JOIN rayon rayon ON objects.rayon = rayon.id
|
|||
|
|
WHERE objects.id IN (
|
|||
|
|
SELECT DISTINCT object_id
|
|||
|
|
FROM object_publish_statistic
|
|||
|
|
WHERE on_moderation = 0 AND user_owner_id IN (" . implode(', ', $usersIdReal) . ") AND
|
|||
|
|
'$startDate' BETWEEN publish_start_date AND publish_end_date
|
|||
|
|
)";
|
|||
|
|
|
|||
|
|
$sqlAdvBeforePeriodObj .= " ORDER BY objects.id ";
|
|||
|
|
|
|||
|
|
$query = mysql_query($sqlAdvBeforePeriodObj);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($post['type'] == 'statsNotAdvInPeriod') {
|
|||
|
|
$sqlNotAdvInPeriodObjCount = "SELECT objects.id FROM objects WHERE $bd_usl_addUsers $bd_piriod_objects and objects.id not in (SELECT id FROM objects WHERE id in (SELECT object_id FROM object_publish_statistic WHERE on_moderation = 0 AND user_owner_id in (" . implode(', ', $usersIdReal) . ") and
|
|||
|
|
(publish_start_date $date_between OR publish_end_date $date_between OR '$startDate' between publish_start_date and publish_end_date)) and $bd_usl_addUsers $bd_piriod_objects) ORDER BY objects.id ";
|
|||
|
|
$rezNotAdvInPeriodObjCount = mysql_query($sqlNotAdvInPeriodObjCount);
|
|||
|
|
$total = mysql_num_rows($rezNotAdvInPeriodObjCount);
|
|||
|
|
|
|||
|
|
$all_pages = ceil($total/$one_page_size);
|
|||
|
|
|
|||
|
|
$sqlNotAdvInPeriodObj = "SELECT objects.*,
|
|||
|
|
rayon.rayon,
|
|||
|
|
DATE_FORMAT(objects.date_add,'%d.%m.%Y %H:%i') AS date_add,
|
|||
|
|
DATE_FORMAT(objects.date_really_add,'%d.%m.%Y %H:%i') AS date_really_add
|
|||
|
|
FROM objects
|
|||
|
|
LEFT JOIN rayon rayon ON objects.rayon = rayon.id
|
|||
|
|
WHERE $bd_usl_addUsers $bd_piriod_objects AND objects.id NOT IN (
|
|||
|
|
SELECT id
|
|||
|
|
FROM objects
|
|||
|
|
WHERE id IN (
|
|||
|
|
SELECT object_id
|
|||
|
|
FROM object_publish_statistic
|
|||
|
|
WHERE on_moderation = 0 AND
|
|||
|
|
user_owner_id IN (" . implode(', ', $usersIdReal) . ") AND
|
|||
|
|
(
|
|||
|
|
publish_start_date $date_between OR
|
|||
|
|
publish_end_date $date_between OR
|
|||
|
|
'$startDate' BETWEEN publish_start_date AND publish_end_date
|
|||
|
|
)
|
|||
|
|
) AND $bd_usl_addUsers $bd_piriod_objects)";
|
|||
|
|
|
|||
|
|
$sqlNotAdvInPeriodObj .= " ORDER BY objects.id";
|
|||
|
|
|
|||
|
|
$query = mysql_query($sqlNotAdvInPeriodObj);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($post['type'] == 'statsAdvCost') {
|
|||
|
|
$sql = "SELECT objects.id
|
|||
|
|
FROM objects
|
|||
|
|
WHERE objects.id IN (
|
|||
|
|
SELECT object_id
|
|||
|
|
FROM object_publish_statistic
|
|||
|
|
WHERE on_moderation = 0 AND
|
|||
|
|
user_owner_id IN (" . implode(', ', $usersIdReal) . ") AND
|
|||
|
|
created_at $date_between
|
|||
|
|
)
|
|||
|
|
ORDER BY objects.id";
|
|||
|
|
|
|||
|
|
$rezAdvCostObjCount = mysql_query($sql);
|
|||
|
|
$total = mysql_num_rows($rezAdvCostObjCount);
|
|||
|
|
$all_pages = ceil($total/$one_page_size);
|
|||
|
|
|
|||
|
|
// Основная статистика
|
|||
|
|
$sqlAdvCostObj = "SELECT objects.*,
|
|||
|
|
rayon.rayon,
|
|||
|
|
DATE_FORMAT(objects.date_add,'%d.%m.%Y %H:%i') AS date_add,
|
|||
|
|
DATE_FORMAT(objects.date_really_add,'%d.%m.%Y %H:%i') AS date_really_add
|
|||
|
|
FROM objects
|
|||
|
|
LEFT JOIN rayon rayon ON objects.rayon = rayon.id
|
|||
|
|
WHERE objects.id IN (
|
|||
|
|
SELECT object_id
|
|||
|
|
FROM object_publish_statistic
|
|||
|
|
WHERE on_moderation = 0 AND user_owner_id IN (" . implode(', ', $usersIdReal) . ") AND
|
|||
|
|
created_at $date_between
|
|||
|
|
)";
|
|||
|
|
|
|||
|
|
$sqlAdvCostObj .= " ORDER BY objects.id";
|
|||
|
|
|
|||
|
|
$query = mysql_query($sqlAdvCostObj);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($post['type'] == 'statsRequests') {
|
|||
|
|
$bd_piriod_req = str_replace('date_add', 'created_at', $bd_piriod);
|
|||
|
|
$who_work_req = " AND ((user_id in (select id from users where id=$user_id or id_manager=$user_id or id_manager in
|
|||
|
|
(select id from users where id_manager=$user_id) or id_manager in (select id from users where id_manager in (select id from users where id_manager=$user_id))) or who_work in (select id from users where id=$user_id or id_manager=$user_id or id_manager in
|
|||
|
|
(select id from users where id_manager=$user_id) or id_manager in (select id from users where id_manager in (select id from users where id_manager=$user_id)))) or doers like '%"".$user_id."":1%')";
|
|||
|
|
$sqlRequestObjCount = "SELECT objects.id FROM objects WHERE $bd_usl_addUsers and objects.id in (SELECT object_id FROM requisitions WHERE 1 $who_work_req $bd_piriod_req and object_id > 0 and type_id=4) ORDER BY objects.id ";
|
|||
|
|
// echo $sqlRequestObjCount;
|
|||
|
|
$rezRequestObjCount = mysql_query($sqlRequestObjCount);
|
|||
|
|
$total = mysql_num_rows($rezRequestObjCount);
|
|||
|
|
|
|||
|
|
$all_pages = ceil($total/$one_page_size);
|
|||
|
|
|
|||
|
|
$sqlRequestObj = "SELECT objects.*, rayon.rayon, DATE_FORMAT(objects.date_add,'%d.%m.%Y %H:%i') as date_add, DATE_FORMAT(objects.date_really_add,'%d.%m.%Y %H:%i') as date_really_add
|
|||
|
|
FROM objects LEFT JOIN rayon rayon on objects.rayon = rayon.id WHERE $bd_usl_addUsers and objects.id in (SELECT object_id FROM requisitions WHERE 1 $who_work_req $bd_piriod_req and object_id > 0 and type_id=4) ORDER BY objects.id";
|
|||
|
|
//echo $sqlRequestObj;
|
|||
|
|
$query = mysql_query($sqlRequestObj);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($post['type'] == 'statsPresentations') {
|
|||
|
|
$sqlPresentationsObjCount = "SELECT objects.id FROM objects WHERE objects.id in (SELECT id_object FROM sended_pdf WHERE id_object in
|
|||
|
|
(SELECT id FROM objects WHERE `date_add` <= '$endDate' and $bd_usl_addUsers) and id_agent in (" . implode(', ', $usersIdReal) . ") and date_send $date_between) ORDER BY objects.id ";
|
|||
|
|
$rezPresentationsObjCount = mysql_query($sqlPresentationsObjCount);
|
|||
|
|
$total = mysql_num_rows($rezPresentationsObjCount);
|
|||
|
|
|
|||
|
|
$all_pages = ceil($total/$one_page_size);
|
|||
|
|
|
|||
|
|
$sqlPresentationsObj = "SELECT objects.*, rayon.rayon, DATE_FORMAT(objects.date_add,'%d.%m.%Y %H:%i') as date_add, DATE_FORMAT(objects.date_really_add,'%d.%m.%Y %H:%i') as date_really_add
|
|||
|
|
FROM objects LEFT JOIN rayon rayon on objects.rayon = rayon.id WHERE objects.id in
|
|||
|
|
(SELECT id_object FROM sended_pdf WHERE id_object in (SELECT id FROM objects WHERE `date_add` <= '$endDate' and $bd_usl_addUsers) and id_agent in (" . implode(', ', $usersIdReal) . ") and date_send $date_between) ORDER BY objects.id ";
|
|||
|
|
|
|||
|
|
$query = mysql_query($sqlPresentationsObj);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($post['type'] == 'statsMeets') {
|
|||
|
|
$sqlMeetsObjCount = "SELECT objects.id FROM objects WHERE objects.id in (SELECT object_id FROM user_object_events WHERE user_id in (". implode(', ', $usersIdReal).") and `type` = 'show' and calendar_view = 1
|
|||
|
|
and schedule_date is not null $whereTasks and DATE_FORMAT(schedule_date, '%Y-%m-%d %H:%i:%s') <= '".date("Y-m-d H:i:s")."')";
|
|||
|
|
$rezMeetsObjCount = mysql_query($sqlMeetsObjCount);
|
|||
|
|
$total = mysql_num_rows($rezMeetsObjCount);
|
|||
|
|
|
|||
|
|
$all_pages = ceil($total/$one_page_size);
|
|||
|
|
|
|||
|
|
$sqlMeetsObj = "SELECT objects.*, rayon.rayon, DATE_FORMAT(objects.date_add,'%d.%m.%Y %H:%i') as date_add, DATE_FORMAT(objects.date_really_add,'%d.%m.%Y %H:%i') as date_really_add
|
|||
|
|
FROM objects LEFT JOIN rayon rayon on objects.rayon = rayon.id WHERE objects.id in
|
|||
|
|
(SELECT object_id FROM user_object_events WHERE user_id in (". implode(', ', $usersIdReal).") and `type` = 'show' and calendar_view = 1
|
|||
|
|
and schedule_date is not null $whereTasks and DATE_FORMAT(schedule_date, '%Y-%m-%d %H:%i:%s') <= '".date("Y-m-d H:i:s")."') ORDER BY objects.id ";
|
|||
|
|
|
|||
|
|
$query = mysql_query($sqlMeetsObj);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($post['type'] == 'statsTaskNew') {
|
|||
|
|
$sqlTaskOldObjCount = "SELECT objects.id FROM objects WHERE objects.id in (SELECT object_id FROM user_object_events WHERE user_id in (". implode(', ', $usersIdReal).") and calendar_view = 0
|
|||
|
|
and schedule_date is not null $whereTasks and DATE_FORMAT(schedule_date, '%Y-%m-%d %H:%i:%s') < '".date("Y-m-d H:i:s")."')";
|
|||
|
|
$rezTaskOldObjCount = mysql_query($sqlTaskOldObjCount);
|
|||
|
|
$total = mysql_num_rows($rezTaskOldObjCount);
|
|||
|
|
|
|||
|
|
$all_pages = ceil($total/$one_page_size);
|
|||
|
|
|
|||
|
|
$sqlTaskOldObj = "SELECT objects.*, rayon.rayon, DATE_FORMAT(objects.date_add,'%d.%m.%Y %H:%i') as date_add, DATE_FORMAT(objects.date_really_add,'%d.%m.%Y %H:%i') as date_really_add
|
|||
|
|
FROM objects LEFT JOIN rayon rayon on objects.rayon = rayon.id WHERE objects.id in
|
|||
|
|
(SELECT object_id FROM user_object_events WHERE user_id in (". implode(', ', $usersIdReal).") and calendar_view = 0
|
|||
|
|
and schedule_date is not null $whereTasks and DATE_FORMAT(schedule_date, '%Y-%m-%d %H:%i:%s') < '".date("Y-m-d H:i:s")."') ORDER BY objects.id ";
|
|||
|
|
|
|||
|
|
$query = mysql_query($sqlTaskOldObj);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($post['type'] == 'statsTaskOld') {
|
|||
|
|
$sqlTaskOldObjCount = "SELECT objects.id FROM objects WHERE objects.id in (SELECT object_id FROM user_object_events WHERE user_id in (". implode(', ', $usersIdReal).") and calendar_view = 0
|
|||
|
|
and schedule_date is not null $whereTasks and DATE_FORMAT(schedule_date, '%Y-%m-%d %H:%i:%s') < '".date("Y-m-d H:i:s")."')";
|
|||
|
|
$rezTaskOldObjCount = mysql_query($sqlTaskOldObjCount);
|
|||
|
|
$total = mysql_num_rows($rezTaskOldObjCount);
|
|||
|
|
|
|||
|
|
$all_pages = ceil($total/$one_page_size);
|
|||
|
|
|
|||
|
|
$sqlTaskOldObj = "SELECT objects.*, rayon.rayon, DATE_FORMAT(objects.date_add,'%d.%m.%Y %H:%i') as date_add, DATE_FORMAT(objects.date_really_add,'%d.%m.%Y %H:%i') as date_really_add
|
|||
|
|
FROM objects LEFT JOIN rayon rayon on objects.rayon = rayon.id WHERE objects.id in
|
|||
|
|
(SELECT object_id FROM user_object_events WHERE user_id in (". implode(', ', $usersIdReal).") and calendar_view = 0
|
|||
|
|
and schedule_date is not null $whereTasks and DATE_FORMAT(schedule_date, '%Y-%m-%d %H:%i:%s') < '".date("Y-m-d H:i:s")."') ORDER BY objects.id ";
|
|||
|
|
|
|||
|
|
$query = mysql_query($sqlTaskOldObj);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($post['type'] == 'statsTaskSlung') {
|
|||
|
|
$sqlTaskSlungObjCount = "SELECT objects.id FROM objects WHERE objects.id in (SELECT object_id FROM user_object_events
|
|||
|
|
WHERE user_id in (". implode(', ', $usersIdReal).") and calendar_view = 1 and schedule_date is not null $whereTasks)";
|
|||
|
|
$rezTaskSlungObjCount = mysql_query($sqlTaskSlungObjCount);
|
|||
|
|
$total = mysql_num_rows($rezTaskSlungObjCount);
|
|||
|
|
|
|||
|
|
$all_pages = ceil($total/$one_page_size);
|
|||
|
|
|
|||
|
|
$sqlTaskSlungObj = "SELECT objects.*, rayon.rayon, DATE_FORMAT(objects.date_add,'%d.%m.%Y %H:%i') as date_add, DATE_FORMAT(objects.date_really_add,'%d.%m.%Y %H:%i') as date_really_add
|
|||
|
|
FROM objects LEFT JOIN rayon rayon on objects.rayon = rayon.id WHERE objects.id in
|
|||
|
|
(SELECT object_id FROM user_object_events WHERE user_id in (". implode(', ', $usersIdReal).") and calendar_view = 1 and schedule_date is not null $whereTasks) ORDER BY objects.id ";
|
|||
|
|
|
|||
|
|
$query = mysql_query($sqlTaskSlungObj);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$columns = json_decode($_POST['columns'], true);
|
|||
|
|
|
|||
|
|
|
|||
|
|
$sheet->setTitle('Объекты');
|
|||
|
|
|
|||
|
|
|
|||
|
|
$arrColExccel = ['B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','AA','AB','AC','AD','AE','AF'];
|
|||
|
|
$columnStart = 'A';
|
|||
|
|
$rowStart = 3;
|
|||
|
|
$tasksId = false;
|
|||
|
|
$closetId = false;
|
|||
|
|
$tempRow = false;
|
|||
|
|
$arrSearch = array();
|
|||
|
|
foreach($columns as $keyCol => $col){
|
|||
|
|
$arrSearch[$col['id']] = $col;
|
|||
|
|
if($col['id'] != 'id'){
|
|||
|
|
if($col['id'] == 'tasks' && $col['visible']){
|
|||
|
|
|
|||
|
|
if(!$tempRow){
|
|||
|
|
$rowStart++;
|
|||
|
|
$tempRow = true;
|
|||
|
|
}
|
|||
|
|
$tasksId = $keyCol;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if($col['id'] == 'closet' && $col['visible']){
|
|||
|
|
if(!$tempRow){
|
|||
|
|
$rowStart++;
|
|||
|
|
$tempRow = true;
|
|||
|
|
}
|
|||
|
|
$closetId = $keyCol;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
$arrayHeder = [$columnStart => ['title'=>'№','width'=>5]];
|
|||
|
|
$arrRows = array();
|
|||
|
|
$j = 0;
|
|||
|
|
$arrPodTask = array();
|
|||
|
|
$arrPodCloset = array();
|
|||
|
|
foreach($columns as $col){
|
|||
|
|
|
|||
|
|
if($col['visible'] && $col['id'] != 'id'){
|
|||
|
|
|
|||
|
|
if($col['id'] != 'tasks' && $col['id'] != 'closet'){
|
|||
|
|
$tempArr['title'] = $col['text'];
|
|||
|
|
if($col['id'] == 'fio'){
|
|||
|
|
$tempArr['width'] = 35;
|
|||
|
|
} else {
|
|||
|
|
$tempArr['width'] = 17;
|
|||
|
|
}
|
|||
|
|
$arrayHeder[$arrColExccel[$j]] = $tempArr;
|
|||
|
|
$arrRows[$arrColExccel[$j]] = $col['id'];
|
|||
|
|
if($col['id'] == 'task' || $col['id'] == 'task_new' || $col['id'] == 'task_old' || $col['id'] == 'task_slung'){
|
|||
|
|
$arrPodTask[] = $arrColExccel[$j];
|
|||
|
|
}
|
|||
|
|
if($col['podcheck'] == 'closet'){
|
|||
|
|
$arrPodCloset[] = $arrColExccel[$j];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
$j++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$textFilters = '';
|
|||
|
|
if(isset($_POST['period'])){
|
|||
|
|
$period = $_POST['period'];
|
|||
|
|
$textFilters .= "Период - ";
|
|||
|
|
switch($period){
|
|||
|
|
case 'today':{
|
|||
|
|
$textFilters .= 'Сегодня';
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
case 'week':{
|
|||
|
|
$textFilters .= 'Неделя';
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
case 'month':{
|
|||
|
|
$textFilters .= 'Месяц';
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
case 'quarter':{
|
|||
|
|
$textFilters .= 'Квартал';
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
case 'year':{
|
|||
|
|
$textFilters .= 'Год';
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
case 'all':{
|
|||
|
|
$textFilters .= 'Все время';
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
case '30days':{
|
|||
|
|
$textFilters .= '30 дней';
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
case '90days':{
|
|||
|
|
$textFilters .= '90 дней';
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
case 'dates':{
|
|||
|
|
if(isset($_POST['onDate'])){
|
|||
|
|
$textFilters .= 'C '.date('d.m.Y', strtotime($_POST['onDate']));
|
|||
|
|
}
|
|||
|
|
if(isset($_POST['offDate'])){
|
|||
|
|
$textFilters .= ' по '.date('d.m.Y', strtotime($_POST['offDate']));
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/*if(isset($_POST['responsible'])){
|
|||
|
|
$responsible = json_decode($_POST['responsible']);
|
|||
|
|
|
|||
|
|
if(!empty($responsible)){
|
|||
|
|
if($textFilters != '') $textFilters .= "; ";
|
|||
|
|
$textFilters .= " Ответственный - ";
|
|||
|
|
foreach($responsible as $emp){
|
|||
|
|
if(strpos($emp, 'allagency_') !== false){
|
|||
|
|
$textFilters .= ' все агенство, ';
|
|||
|
|
} else if (strpos($emp, 'all_') !== false){
|
|||
|
|
$user_id = str_replace('all_', '', $emp);
|
|||
|
|
$textFilters .= ' вся группа менеджера ';
|
|||
|
|
$sql = "SELECT first_name, last_name, middle_name FROM users WHERE id=".$user_id;
|
|||
|
|
$q = mysql_query($sql);
|
|||
|
|
$r = mysql_fetch_assoc($q);
|
|||
|
|
$textFilters .= trim($r['last_name'] . ' ' . $r['first_name'] . ' ' . $r['middle_name']).', ';
|
|||
|
|
} else {
|
|||
|
|
$sql = "SELECT first_name, last_name, middle_name, manager FROM users WHERE id=".$emp;
|
|||
|
|
//echo $sql;
|
|||
|
|
$post = ' агент ';
|
|||
|
|
$q = mysql_query($sql);
|
|||
|
|
$r = mysql_fetch_assoc($q);
|
|||
|
|
if($r['manager'] == 1){
|
|||
|
|
$post = ' менеджер ';
|
|||
|
|
}
|
|||
|
|
$textFilters .= $post.' '.trim($r['last_name'] . ' ' . $r['first_name'] . ' ' . $r['middle_name']).', ';
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
$textFilters = mb_substr($textFilters,0,-2);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}*/
|
|||
|
|
|
|||
|
|
if(isset($_POST['charts_type'])){
|
|||
|
|
$charts_type = json_decode($_POST['charts_type']);
|
|||
|
|
if(!empty($charts_type)){
|
|||
|
|
if($textFilters != '') $textFilters .= "; ";
|
|||
|
|
$textFilters .= " ТИП: ";
|
|||
|
|
foreach($charts_type as $chart){
|
|||
|
|
$textFilters .= ' '.$chart.', ';
|
|||
|
|
}
|
|||
|
|
$textFilters = mb_substr($textFilters,0,-2);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
if(isset($_POST['charts_objects_type'])){
|
|||
|
|
$charts_objects_type = json_decode($_POST['charts_objects_type']);
|
|||
|
|
if(!empty($charts_objects_type)){
|
|||
|
|
if($textFilters != '') $textFilters .= "; ";
|
|||
|
|
$textFilters .= " Тип недвижимости - ";
|
|||
|
|
foreach($charts_objects_type as $object){
|
|||
|
|
$textFilters .= ' '.str_replace(['к_кв','__', '_'],['к.кв.', ' ',' '],$object).', ';
|
|||
|
|
}
|
|||
|
|
$textFilters = mb_substr($textFilters,0,-2);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(isset($_POST['charts_rol'])){
|
|||
|
|
$charts_rol = json_decode($_POST['charts_rol']);
|
|||
|
|
if(!empty($charts_rol)){
|
|||
|
|
if($textFilters != '') $textFilters .= "; ";
|
|||
|
|
$textFilters .= " Роль клиента - ";
|
|||
|
|
foreach($charts_rol as $rol){
|
|||
|
|
$textFilters .= ' '.$rol.', ';
|
|||
|
|
}
|
|||
|
|
$textFilters = mb_substr($textFilters,0,-2);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(isset($_POST['source'])){
|
|||
|
|
$sources = json_decode($_POST['source']);
|
|||
|
|
if(!empty($sources)){
|
|||
|
|
if($textFilters != '') $textFilters .= "; ";
|
|||
|
|
$textFilters .= " Источник - ";
|
|||
|
|
$sql = "SELECT source FROM advertising_sources WHERE id in (".implode(',', $sources).")";
|
|||
|
|
|
|||
|
|
$q = mysql_query($sql);
|
|||
|
|
while($r = mysql_fetch_assoc($q)){
|
|||
|
|
$textFilters .= $r['source'].', ';
|
|||
|
|
}
|
|||
|
|
$textFilters = mb_substr($textFilters,0,-2);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
if(isset($_POST['funnel'])){
|
|||
|
|
$funnels = json_decode($_POST['funnel']);
|
|||
|
|
if(!empty($funnels)){
|
|||
|
|
if($textFilters != '') $textFilters .= "; ";
|
|||
|
|
$textFilters .= " Воронки - ";
|
|||
|
|
$sql = "SELECT id, name FROM funnel WHERE id in (".implode(',', $funnels).")";
|
|||
|
|
|
|||
|
|
$q = mysql_query($sql);
|
|||
|
|
while($r = mysql_fetch_assoc($q)){
|
|||
|
|
$textFilters .= $r['name'].', ';
|
|||
|
|
}
|
|||
|
|
$textFilters = mb_substr($textFilters,0,-2);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
$sheet->setCellValue('B1', "ФИЛЬТРЫ: ");
|
|||
|
|
$sheet->getStyle('B1')->getFont()->applyFromArray( [ 'name' => 'Arial', 'bold' => TRUE, 'italic' => FALSE, 'strikethrough' => FALSE, 'color' => [ 'rgb' => '808080' ] ] );
|
|||
|
|
$sheet->getStyle('B')->getAlignment()->setWrapText(true);
|
|||
|
|
$sheet->getStyle('B1')->getAlignment()->setWrapText(true);
|
|||
|
|
|
|||
|
|
$sheet->setCellValue('C1', $textFilters);
|
|||
|
|
$sheet->mergeCells('C1:'.$arrColExccel[$j-1].'1');
|
|||
|
|
|
|||
|
|
|
|||
|
|
if($tasksId){
|
|||
|
|
$sheet->setCellValue($arrPodTask[0].($rowStart-1), $columns[$tasksId]['text']);
|
|||
|
|
$sheet->getStyle($arrPodTask[0].($rowStart-1))->getFont()->applyFromArray( [ 'name' => 'Arial', 'bold' => TRUE, 'italic' => FALSE, 'strikethrough' => FALSE, 'color' => [ 'rgb' => '808080' ] ] );
|
|||
|
|
$sheet->getStyle($arrPodTask[0])->getAlignment()->setWrapText(true);
|
|||
|
|
$sheet->getStyle($arrPodTask[0].($rowStart-1))->getAlignment()->setWrapText(true);
|
|||
|
|
|
|||
|
|
$sheet->mergeCells($arrPodTask[0].($rowStart-1).':'.$arrPodTask[count($arrPodTask)-1].($rowStart-1));
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if($closetId){
|
|||
|
|
$sheet->setCellValue($arrPodCloset[0].($rowStart-1), $columns[$closetId]['text']);
|
|||
|
|
$sheet->getStyle($arrPodCloset[0].($rowStart-1))->getFont()->applyFromArray( [ 'name' => 'Arial', 'bold' => TRUE, 'italic' => FALSE, 'strikethrough' => FALSE, 'color' => [ 'rgb' => '808080' ] ] );
|
|||
|
|
$sheet->getStyle($arrPodCloset[0])->getAlignment()->setWrapText(true);
|
|||
|
|
$sheet->getStyle($arrPodCloset[0].($rowStart-1))->getAlignment()->setWrapText(true);
|
|||
|
|
|
|||
|
|
$sheet->mergeCells($arrPodCloset[0].($rowStart-1).':'.$arrPodCloset[count($arrPodCloset)-1].($rowStart-1));
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$styleArray = array(
|
|||
|
|
'borders' => array(
|
|||
|
|
'allBorders' => array(
|
|||
|
|
'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
|
|||
|
|
'color' => array('rgb' => '808080'),
|
|||
|
|
),
|
|||
|
|
),
|
|||
|
|
);
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
foreach($arrayHeder as $h => $w){
|
|||
|
|
$sheet->setCellValue($h.$rowStart, $w['title']);
|
|||
|
|
$sheet->getColumnDimension($h)->setWidth($w['width']);
|
|||
|
|
$sheet->getStyle($h.$rowStart)->getFont()->applyFromArray( [ 'name' => 'Arial', 'bold' => TRUE, 'italic' => FALSE, 'strikethrough' => FALSE, 'color' => [ 'rgb' => '808080' ], ] );
|
|||
|
|
|
|||
|
|
$sheet->getStyle($h)->getAlignment()->setWrapText(true);
|
|||
|
|
$sheet->getStyle($h.$rowStart)->getAlignment()->setWrapText(true);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$i = $rowStart+1;
|
|||
|
|
$k = 1;
|
|||
|
|
|
|||
|
|
while ($obj = mysql_fetch_assoc($query)) {
|
|||
|
|
|
|||
|
|
$sqlPhotoInfo = "SELECT oop.sort_order, p.photo FROM objects_object_photo oop, object_photo p WHERE p.id = oop.object_photo_id AND oop.object_id = $obj[id] ORDER BY oop.sort_order";
|
|||
|
|
$rezPhotoInfo = mysql_query($sqlPhotoInfo);
|
|||
|
|
|
|||
|
|
if (mysql_num_rows($rezPhotoInfo) > 0) {
|
|||
|
|
while ($photoInfo = mysql_fetch_assoc($rezPhotoInfo)) {
|
|||
|
|
$obj['photo' . $photoInfo['sort_order']] = $photoInfo['photo'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/*****************/
|
|||
|
|
|
|||
|
|
$type = 'Объект';
|
|||
|
|
|
|||
|
|
switch ($obj['type']) {
|
|||
|
|
case 1:
|
|||
|
|
if ($obj['komnat'] == 1 && $obj['studio_flag']) {
|
|||
|
|
$type = "Квартира-студия";
|
|||
|
|
} else {
|
|||
|
|
$type = "$obj[komnat]-комнатная квартира";
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
case 2:
|
|||
|
|
|
|||
|
|
$type = "Комната в $obj[komnat]-комнатной квартире";
|
|||
|
|
break;
|
|||
|
|
case 3:
|
|||
|
|
$type = "$obj[komnat]-комнатный дом";
|
|||
|
|
break;
|
|||
|
|
case 4:
|
|||
|
|
switch ($obj['type_category']){
|
|||
|
|
case 1:
|
|||
|
|
$type = "Офис";
|
|||
|
|
break;
|
|||
|
|
case 2:
|
|||
|
|
$type = "Склад";
|
|||
|
|
break;
|
|||
|
|
case 3:
|
|||
|
|
$type = "Торговая площадь";
|
|||
|
|
break;
|
|||
|
|
case 4:
|
|||
|
|
$type = "Производство";
|
|||
|
|
break;
|
|||
|
|
case 5:
|
|||
|
|
$type = "Помещение свободного назначения";
|
|||
|
|
break;
|
|||
|
|
case 6:
|
|||
|
|
$type = "Здание";
|
|||
|
|
break;
|
|||
|
|
case 7:
|
|||
|
|
$type = "Гараж";
|
|||
|
|
break;
|
|||
|
|
case 8:
|
|||
|
|
$type = "Готовый бизнес";
|
|||
|
|
break;
|
|||
|
|
case 9:
|
|||
|
|
$type = "Коммерческая земля";
|
|||
|
|
break;
|
|||
|
|
default: $type = "Помещение";
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
case 5:
|
|||
|
|
$type = "Часть дома";
|
|||
|
|
break;
|
|||
|
|
case 6:
|
|||
|
|
$type = "Комплекс";
|
|||
|
|
break;
|
|||
|
|
case 7:
|
|||
|
|
$type = "Участок";
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
$type = "$obj[komnat]-комнатная квартира";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$mtr = array();
|
|||
|
|
$sql = "SELECT metro.metro FROM metro, sp_metro WHERE sp_metro.id_metro = metro.id AND sp_metro.id_obj = $obj[id]";
|
|||
|
|
$result = mysql_query($sql);
|
|||
|
|
while ($m = mysql_fetch_row($result)) {
|
|||
|
|
$mtr[] = $m[0];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$metroRayon = '';
|
|||
|
|
|
|||
|
|
if ($obj['rayon']) {
|
|||
|
|
$metroRayon .= $obj['rayon'] . ' район';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (count($mtr) > 0) {
|
|||
|
|
$metroRayon .= ' / ' . implode(", ", $mtr);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$address = $obj['adres'];
|
|||
|
|
|
|||
|
|
if ($obj['dom']) {
|
|||
|
|
$address = $address . ", " . $obj['dom'];
|
|||
|
|
}
|
|||
|
|
if ($obj['korpus']) {
|
|||
|
|
$address = $address . ", корпус " . $obj['korpus'];
|
|||
|
|
}
|
|||
|
|
if ($obj['litera']) {
|
|||
|
|
$address = $address . ", литера " . $obj['litera'];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$etazh = '';
|
|||
|
|
|
|||
|
|
if ($obj['type'] == 3) {
|
|||
|
|
if ($obj['etazh_iz'] * 1 != 0) {
|
|||
|
|
$etazh = $obj['etazh_iz'] . " этажей";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($obj['etazh'] * 1 != 0) {
|
|||
|
|
$etazh = $obj['etazh'] . ' этаж';
|
|||
|
|
if ((int)$obj['etazh'] == 1 && !empty($obj['etaz_first_type'])) {
|
|||
|
|
$etazh = $etaz_first_types[$obj['etaz_first_type']];
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
if ($obj['etazh_iz'] * 1 != 0) {
|
|||
|
|
$etazh .= " из " . $obj['etazh_iz'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
list($dateAdd, $timeAdd) = explode(" ", $obj['date_add']);
|
|||
|
|
list($d, $m, $y) = explode(".", $dateAdd);
|
|||
|
|
|
|||
|
|
$date_add = $d . " " . getRusMonth($m) . " " . $y;
|
|||
|
|
$updateDate = $date_add . " " . $timeAdd;
|
|||
|
|
|
|||
|
|
list($dateAdd, $timeAdd) = explode(" ", $obj['date_really_add']);
|
|||
|
|
list($d, $m, $y) = explode(".", $dateAdd);
|
|||
|
|
|
|||
|
|
$date_add = $d . " " . getRusMonth($m) . " " . $y;
|
|||
|
|
$createDate = $date_add . " " . $timeAdd;
|
|||
|
|
|
|||
|
|
$agentData = mysql_fetch_assoc(mysql_query("SELECT first_name, last_name, middle_name, id_manager FROM users WHERE id=" . $obj['id_add_user']));
|
|||
|
|
$agentData['fio'] = trim($agentData['last_name'] . ' ' . $agentData['first_name'] . ' ' . $agentData['middle_name']);
|
|||
|
|
|
|||
|
|
$managerData = [];
|
|||
|
|
if (isset($agentData['id_manager']) && $agentData['id_manager']) {
|
|||
|
|
$managerData = mysql_fetch_assoc(mysql_query("SELECT first_name, last_name, middle_name, id_manager FROM users WHERE id=" . $agentData['id_manager']));
|
|||
|
|
$managerData['fio'] = trim($managerData['last_name'] . ' ' . $managerData['first_name'] . ' ' . $managerData['middle_name']);
|
|||
|
|
} else {
|
|||
|
|
$managerData['fio'] = $agentData['fio'];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$clients = '[';
|
|||
|
|
$clientObjIds = [];
|
|||
|
|
$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)){
|
|||
|
|
$clientObjIds[] = $r_cl_obj['client_id'];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$sql_clients = "SELECT `id`, `fio`, `email` FROM `clients` WHERE id in (".implode(',', $clientObjIds).")";
|
|||
|
|
$q_client = mysql_query($sql_clients);
|
|||
|
|
if (mysql_num_rows($q_client) > 0) {
|
|||
|
|
|
|||
|
|
$clCount = 0;
|
|||
|
|
while ($client = mysql_fetch_assoc($q_client)) {
|
|||
|
|
if ($clCount > 0) {
|
|||
|
|
$clients .= ',';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$clients = $clients . '{"fio": "' . $client['fio'] . '", "id" : "' . $client['id'] . '"}';
|
|||
|
|
$clCount++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$clients .= ']';
|
|||
|
|
|
|||
|
|
$who_work_req = " AND ((user_id in (select id from users where id=$user_id or id_manager=$user_id or id_manager in
|
|||
|
|
(select id from users where id_manager=$user_id)) or who_work in (select id from users where id=$user_id or id_manager=$user_id or id_manager in
|
|||
|
|
(select id from users where id_manager=$user_id))) or doers like '%"".$user_id."":1%')";
|
|||
|
|
$bd_piriod_req = str_replace('date_add', 'created_at', $bd_piriod);
|
|||
|
|
$sqlRequest = "SELECT id FROM requisitions WHERE 1 $who_work_req $bd_piriod_req and object_id = $obj[id] and (type_id = 4 or type_id in (SELECT id FROM requisitions_type WHERE heir = 4 AND agency_id = {$user->agencyId}))";
|
|||
|
|
$qRequest = mysql_query($sqlRequest);
|
|||
|
|
|
|||
|
|
|
|||
|
|
$requestsCount = mysql_num_rows($qRequest);
|
|||
|
|
|
|||
|
|
$sqlPresentation = "SELECT id FROM sended_pdf WHERE id_object = $obj[id] and date_send $date_between";
|
|||
|
|
$rezPresentation = mysql_query($sqlPresentation);
|
|||
|
|
$presentationsCount = mysql_num_rows($rezPresentation);
|
|||
|
|
|
|||
|
|
$sqlMeet = "SELECT id FROM user_object_events WHERE object_id = $obj[id] and `type` = 'meet' and calendar_view = 1
|
|||
|
|
and schedule_date is not null $whereTasks and DATE_FORMAT(schedule_date, '%Y-%m-%d %H:%i:%s') <= '".date("Y-m-d H:i:s")."'";
|
|||
|
|
$rezMeet = mysql_query($sqlMeet);
|
|||
|
|
$meetCount = mysql_num_rows($rezMeet);
|
|||
|
|
|
|||
|
|
$packs = '';
|
|||
|
|
|
|||
|
|
$sqlAdvInPeriod = "SELECT id, name FROM `advertising_package` where id in (SELECT advertising_package_id from advertising_package_object_publish where id in (SELECT DISTINCT advertising_package_object_publish_id FROM object_publish_statistic WHERE on_moderation = 0 AND user_owner_id in (" . implode(', ', $usersIdReal) . ") and
|
|||
|
|
(publish_start_date $date_between OR publish_end_date $date_between OR '$startDate' between publish_start_date and publish_end_date) and object_id=$obj[id]))";
|
|||
|
|
$rezAdvInPeriod = mysql_query($sqlAdvInPeriod);
|
|||
|
|
|
|||
|
|
if (mysql_num_rows($rezAdvInPeriod) > 0) {
|
|||
|
|
|
|||
|
|
while ($pack = mysql_fetch_assoc($rezAdvInPeriod)) {
|
|||
|
|
$packs = $packs . $pack['name'] . "; ";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$minDate = '';
|
|||
|
|
$maxDate = '';
|
|||
|
|
$sumPrice = 0;
|
|||
|
|
$periods = [];
|
|||
|
|
$periodsCount = 0;
|
|||
|
|
|
|||
|
|
$sqlDatesAndPriceInPeriod = "SELECT publish_start_date, publish_end_date, price, created_at, days_count FROM object_publish_statistic WHERE on_moderation = 0 AND user_owner_id in (" . implode(', ', $usersIdReal) . ") and
|
|||
|
|
(publish_start_date $date_between OR publish_end_date $date_between OR '$startDate' between publish_start_date and publish_end_date) and object_id=$obj[id]";
|
|||
|
|
$rezDatesAndSumInPeriod = mysql_query($sqlDatesAndPriceInPeriod);
|
|||
|
|
|
|||
|
|
while ($statRec = mysql_fetch_assoc($rezDatesAndSumInPeriod)) {
|
|||
|
|
if (!$minDate) {
|
|||
|
|
$minDate = $statRec['publish_start_date'];
|
|||
|
|
} else {
|
|||
|
|
if (strtotime($minDate) > strtotime($statRec['publish_start_date'])) {
|
|||
|
|
$minDate = $statRec['publish_start_date'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if ($statRec['days_count'] != 5000) {
|
|||
|
|
if (!$maxDate) {
|
|||
|
|
$maxDate = $statRec['publish_end_date'];
|
|||
|
|
} else {
|
|||
|
|
if (strtotime($maxDate) < strtotime($statRec['publish_end_date'])) {
|
|||
|
|
$maxDate = $statRec['publish_end_date'];
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (strtotime($statRec['created_at']) > strtotime($startDate) && strtotime($statRec['created_at']) < strtotime($endDate)) {
|
|||
|
|
$sumPrice = $sumPrice + $statRec['price'];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ($periodsCount == 0) {
|
|||
|
|
$p['publish_start_date'] = $statRec['publish_start_date'];
|
|||
|
|
$p['publish_end_date'] = $statRec['days_count'] != 5000 ? $statRec['publish_end_date'] : '-';
|
|||
|
|
$periods[] = $p;
|
|||
|
|
$periodsCount++;
|
|||
|
|
} else {
|
|||
|
|
$found = false;
|
|||
|
|
foreach ($periods as $key => $period) {
|
|||
|
|
if ($period['publish_start_date'] === $statRec['publish_start_date'] && $period['publish_end_date'] === $statRec['publish_end_date'] ){
|
|||
|
|
//тот же период, ничего не делаем
|
|||
|
|
$found = true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (!$found) {
|
|||
|
|
$p['publish_start_date'] = $statRec['publish_start_date'];
|
|||
|
|
$p['publish_end_date'] = $statRec['days_count'] != 5000 ? $statRec['publish_end_date'] : '-';
|
|||
|
|
$periods[] = $p;
|
|||
|
|
$periodsCount++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$days = [];
|
|||
|
|
|
|||
|
|
foreach ($periods as $key => $period) {
|
|||
|
|
if ($period['publish_end_date'] != '-') {
|
|||
|
|
$startStr = date("Y-m-d", strtotime($period['publish_start_date']));
|
|||
|
|
$endStr = date("Y-m-d", strtotime($period['publish_end_date']));
|
|||
|
|
|
|||
|
|
$startAsDate = strtotime(date("Y-m-d", strtotime($period['publish_start_date'])));
|
|||
|
|
$endAsDate = strtotime(date("Y-m-d", strtotime($period['publish_end_date'])));
|
|||
|
|
|
|||
|
|
$foundStart = false;
|
|||
|
|
$foundEnd = false;
|
|||
|
|
foreach ($days as $dayKey => $day) {
|
|||
|
|
if ($day === $startStr) {
|
|||
|
|
$foundStart = true;
|
|||
|
|
}
|
|||
|
|
if ($day === $endStr) {
|
|||
|
|
$foundEnd = true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (!$foundStart) {
|
|||
|
|
$days[] = $startStr;
|
|||
|
|
}
|
|||
|
|
if (!$foundEnd) {
|
|||
|
|
$days[] = $endStr;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
while (true) {
|
|||
|
|
if ($startStr === $endStr) {
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (strtotime($startStr) > strtotime($endStr)) {
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$startStr = date('Y-m-d', strtotime($startStr . ' + 1 days'));
|
|||
|
|
|
|||
|
|
$found = false;
|
|||
|
|
foreach ($days as $dayKey => $day) {
|
|||
|
|
if ($day === $startStr) {
|
|||
|
|
$found = true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (!$found) {
|
|||
|
|
$days[] = $startStr;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$photo = "";
|
|||
|
|
for ($num = 1; $num <= 20; $num++) {
|
|||
|
|
if ($obj['photo' . $num]) {
|
|||
|
|
if(stripos($obj['photo'.$num],"http://") === false) {
|
|||
|
|
$obj['photo'.$num] = "/photos/".$obj['photo'.$num];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if($obj['photo'.$num]) {
|
|||
|
|
$photo = $obj['photo'.$num];
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
$user = new User;
|
|||
|
|
$user->get($_SESSION[id]);
|
|||
|
|
$agency_id = $user->agencyId;
|
|||
|
|
$sql = "SELECT *
|
|||
|
|
FROM `object_prices`
|
|||
|
|
WHERE `object_id`='$obj[id]' AND
|
|||
|
|
`agency_id`='$agency_id' LIMIT 1";
|
|||
|
|
|
|||
|
|
if ($query_stat = mysql_query($sql)) {
|
|||
|
|
$row_stat = mysql_fetch_assoc($query_stat);
|
|||
|
|
|
|||
|
|
if (!is_null($row_stat['prep_price']))
|
|||
|
|
$obj['prep_price'] = $row_stat['prep_price'];
|
|||
|
|
else
|
|||
|
|
$obj['prep_price'] = '-';
|
|||
|
|
|
|||
|
|
if (!is_null($row_stat['start_price']))
|
|||
|
|
$obj['start_price'] = $row_stat['start_price'];
|
|||
|
|
else
|
|||
|
|
$obj['start_price'] = '-';
|
|||
|
|
|
|||
|
|
if (!is_null($row_stat['fact_price']))
|
|||
|
|
$obj['fact_price'] = $row_stat['fact_price'];
|
|||
|
|
else
|
|||
|
|
$obj['fact_price'] = '-';
|
|||
|
|
}
|
|||
|
|
/****************/
|
|||
|
|
|
|||
|
|
$sheet->setCellValue('A'.$i, $k);
|
|||
|
|
$j = 0;
|
|||
|
|
if(isset($arrSearch['preview']) && $arrSearch['preview']['visible']){
|
|||
|
|
$sheet->setCellValue($arrColExccel[$j].$i,$photo);
|
|||
|
|
$j++;
|
|||
|
|
}
|
|||
|
|
if(isset($arrSearch['type']) && $arrSearch['type']['visible']){
|
|||
|
|
$operation_type = $obj['operation_type'] == 1 ? "Продажа" : "Аренда";
|
|||
|
|
$sheet->setCellValue($arrColExccel[$j].$i,$operation_type);
|
|||
|
|
$j++;
|
|||
|
|
}
|
|||
|
|
if(isset($arrSearch['objType']) && $arrSearch['objType']['visible']){
|
|||
|
|
$sheet->setCellValue($arrColExccel[$j].$i,$type);
|
|||
|
|
$j++;
|
|||
|
|
}
|
|||
|
|
if(isset($arrSearch['metro']) && $arrSearch['metro']['visible']){
|
|||
|
|
$sheet->setCellValue($arrColExccel[$j].$i,$metroRayon);
|
|||
|
|
$j++;
|
|||
|
|
}
|
|||
|
|
if(isset($arrSearch['address']) && $arrSearch['address']['visible']){
|
|||
|
|
$sheet->setCellValue($arrColExccel[$j].$i,$address);
|
|||
|
|
$j++;
|
|||
|
|
}
|
|||
|
|
if(isset($arrSearch['allArea']) && $arrSearch['allArea']['visible']){
|
|||
|
|
$allArea = $obj['type'] == 7 ? $obj['land_area'] * 1 : $obj['ploshad'] * 1;
|
|||
|
|
$sheet->setCellValue($arrColExccel[$j].$i,$allArea);
|
|||
|
|
$j++;
|
|||
|
|
}
|
|||
|
|
if(isset($arrSearch['liveArea']) && $arrSearch['liveArea']['visible']){
|
|||
|
|
|
|||
|
|
$sheet->setCellValue($arrColExccel[$j].$i,$obj['ploshad_komn']);
|
|||
|
|
$j++;
|
|||
|
|
}
|
|||
|
|
if(isset($arrSearch['kitchenArea']) && $arrSearch['kitchenArea']['visible']){
|
|||
|
|
|
|||
|
|
$sheet->setCellValue($arrColExccel[$j].$i,$obj['ploshad_k'] * 1);
|
|||
|
|
$j++;
|
|||
|
|
}
|
|||
|
|
if(isset($arrSearch['floor']) && $arrSearch['floor']['visible']){
|
|||
|
|
|
|||
|
|
$sheet->setCellValue($arrColExccel[$j].$i,$etazh);
|
|||
|
|
$j++;
|
|||
|
|
}
|
|||
|
|
if(isset($arrSearch['price']) && $arrSearch['price']['visible']){
|
|||
|
|
|
|||
|
|
$sheet->setCellValue($arrColExccel[$j].$i,number_format($obj['stoim'], 0, ',', ' '));
|
|||
|
|
$j++;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(isset($arrSearch['prep_price']) && $arrSearch['prep_price']['visible']){
|
|||
|
|
|
|||
|
|
$sheet->setCellValue($arrColExccel[$j].$i,number_format($obj['prep_price'], 0, ',', ' '));
|
|||
|
|
$j++;
|
|||
|
|
}
|
|||
|
|
if(isset($arrSearch['start_price']) && $arrSearch['start_price']['visible']){
|
|||
|
|
|
|||
|
|
$sheet->setCellValue($arrColExccel[$j].$i,number_format($obj['start_price'], 0, ',', ' '));
|
|||
|
|
$j++;
|
|||
|
|
}
|
|||
|
|
if(isset($arrSearch['fact_price']) && $arrSearch['fact_price']['visible']){
|
|||
|
|
|
|||
|
|
$sheet->setCellValue($arrColExccel[$j].$i,number_format($obj['fact_price'], 0, ',', ' '));
|
|||
|
|
$j++;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
if(isset($arrSearch['manager']) && $arrSearch['manager']['visible']){
|
|||
|
|
|
|||
|
|
$sheet->setCellValue($arrColExccel[$j].$i,$managerData['fio']);
|
|||
|
|
$j++;
|
|||
|
|
}
|
|||
|
|
if(isset($arrSearch['agent']) && $arrSearch['agent']['visible']){
|
|||
|
|
|
|||
|
|
$sheet->setCellValue($arrColExccel[$j].$i,$agentData['fio']);
|
|||
|
|
$j++;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(isset($arrSearch['client']) && $arrSearch['client']['visible']){
|
|||
|
|
$client = '';
|
|||
|
|
if(!empty(json_decode($clients))){
|
|||
|
|
$client = json_decode($clients)[0];
|
|||
|
|
if(isset($client->fio)){
|
|||
|
|
$client = $client->fio;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
$sheet->setCellValue($arrColExccel[$j].$i,$client);
|
|||
|
|
$j++;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(isset($arrSearch['createDate']) && $arrSearch['createDate']['visible']){
|
|||
|
|
|
|||
|
|
$sheet->setCellValue($arrColExccel[$j].$i,$createDate);
|
|||
|
|
$j++;
|
|||
|
|
}
|
|||
|
|
if(isset($arrSearch['updateDate']) && $arrSearch['updateDate']['visible']){
|
|||
|
|
|
|||
|
|
$sheet->setCellValue($arrColExccel[$j].$i,$updateDate);
|
|||
|
|
$j++;
|
|||
|
|
}
|
|||
|
|
if(isset($arrSearch['requests']) && $arrSearch['requests']['visible']){
|
|||
|
|
|
|||
|
|
$sheet->setCellValue($arrColExccel[$j].$i,$requestsCount);
|
|||
|
|
$j++;
|
|||
|
|
}
|
|||
|
|
if(isset($arrSearch['presentations']) && $arrSearch['presentations']['visible']){
|
|||
|
|
|
|||
|
|
$sheet->setCellValue($arrColExccel[$j].$i,$presentationsCount);
|
|||
|
|
$j++;
|
|||
|
|
}
|
|||
|
|
if(isset($arrSearch['meets']) && $arrSearch['meets']['visible']){
|
|||
|
|
|
|||
|
|
$sheet->setCellValue($arrColExccel[$j].$i,$meetCount);
|
|||
|
|
$j++;
|
|||
|
|
}
|
|||
|
|
if(isset($arrSearch['advPacks']) && $arrSearch['advPacks']['visible']){
|
|||
|
|
|
|||
|
|
$sheet->setCellValue($arrColExccel[$j].$i,$packs);
|
|||
|
|
$j++;
|
|||
|
|
}
|
|||
|
|
if(isset($arrSearch['advStart']) && $arrSearch['advStart']['visible']){
|
|||
|
|
$m_date = $minDate ? date("d.m.Y", strtotime($minDate)) : '';
|
|||
|
|
$sheet->setCellValue($arrColExccel[$j].$i,$m_date);
|
|||
|
|
$j++;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(isset($arrSearch['advEnd']) && $arrSearch['advEnd']['visible']){
|
|||
|
|
$m_date = $maxDate ? date("d.m.Y", strtotime($maxDate)) : '';
|
|||
|
|
$sheet->setCellValue($arrColExccel[$j].$i,$m_date);
|
|||
|
|
$j++;
|
|||
|
|
}
|
|||
|
|
if(isset($arrSearch['daysCount']) && $arrSearch['daysCount']['visible']){
|
|||
|
|
|
|||
|
|
$sheet->setCellValue($arrColExccel[$j].$i,count($days));
|
|||
|
|
$j++;
|
|||
|
|
}
|
|||
|
|
if(isset($arrSearch['adv_price']) && $arrSearch['adv_price']['visible']){
|
|||
|
|
|
|||
|
|
$sheet->setCellValue($arrColExccel[$j].$i,number_format($sumPrice, 2, '.', ' '));
|
|||
|
|
$j++;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$i++;
|
|||
|
|
$k++;
|
|||
|
|
}
|
|||
|
|
$sheet ->getStyle('A'.($rowStart).':'.$arrColExccel[$j-1].($rowStart + mysql_num_rows($query)))->applyFromArray($styleArray);
|
|||
|
|
|
|||
|
|
/*foreach($rows as $row){
|
|||
|
|
$sheet->setCellValue('A'.$i, $k);
|
|||
|
|
$j = 0;
|
|||
|
|
foreach($arrRows as $ar){
|
|||
|
|
if($ar == 'task'){
|
|||
|
|
$val = (int)$row['task_new'] + (int)$row['task_old'] + (int)$row['task_slung'];
|
|||
|
|
$sheet->setCellValue($arrColExccel[$j].$i, $val);
|
|||
|
|
} else {
|
|||
|
|
$sheet->setCellValue($arrColExccel[$j].$i, $row[$ar]);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$j++;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$i++;
|
|||
|
|
$k++;
|
|||
|
|
}*/
|
|||
|
|
|
|||
|
|
|
|||
|
|
$writer = new Xlsx($spreadsheet);
|
|||
|
|
//echo $_SERVER['DOCUMENT_ROOT'].'server/excel';
|
|||
|
|
if(!file_exists($_SERVER['DOCUMENT_ROOT'].'/server/excel')){
|
|||
|
|
mkdir($_SERVER['DOCUMENT_ROOT'].'/server/excel', 0777);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
$name_file = '/server/excel/objects_'.$date.'.xlsx';
|
|||
|
|
$name = 'objects_'.$date.'.xlsx';
|
|||
|
|
|
|||
|
|
|
|||
|
|
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx');
|
|||
|
|
$writer->save($_SERVER['DOCUMENT_ROOT'].$name_file);
|
|||
|
|
$res['file'] = $name_file;
|
|||
|
|
$res['result'] = 'ok';
|
|||
|
|
$res['name'] = $name;
|
|||
|
|
echo json_encode($res);
|