Joywork/admin/blocks.php
2026-05-22 21:21:54 +03:00

195 lines
6.3 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
require_once($_SERVER['DOCUMENT_ROOT'] . "/config.php");
ini_set('display_errors', 1);
error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE);
// закрываем доступ на выполнение запросов
if (!isset($_SESSION['superadmin'])) {
header("location:/index.php");
die("Доступ запрещён!");
}
include $_SERVER['DOCUMENT_ROOT'] . '/import/obj/ImportRecord.php';
include $_SERVER['DOCUMENT_ROOT'] . '/import/document/target/DocTarget.php';
include $_SERVER['DOCUMENT_ROOT'] . '/import/obj/Block.php';
include $_SERVER['DOCUMENT_ROOT'] . '/import/ImporterService.php';
include $_SERVER['DOCUMENT_ROOT'] . '/import/obj/BlockImage.php';
$importerService = new ImporterService();
$willBeRun = $importerService->isForceFlatshopImportStart();
$isImporterActive = $importerService->isFlatshopActive();
if (isset($_GET['run']) && $_GET['run'] == 1) {
$importerService->setForceFlatshopImport(1);
header("location:/admin/blocks.php");
}
require_once($_SERVER['DOCUMENT_ROOT'] . "/templates/header-admin.php");
?>
<div class="main-title">
<h1>Комплексы</h1>
</div>
<div class="users fr__users" style="margin-right: 20px;">
<div class="head-filter__top">
<div class="top-line">
<div class="head-filter-search">
<div class="form-search">
<form>
<input type="search" name="search" class="text" placeholder="Название"
value="<?php if (isset($_GET['search'])) {
echo $_GET['search'];
} ?>">
<span class="search-icon">
<i class="ti-search"></i>
</span>
</form>
</div>
</div>
<div class="clear"></div>
</div>
</div>
<?php
$num_on_page = 20;
if (isset($_GET['page'])) {
$page = $_GET['page'];
} else {
$page = 1;
}
$from = ($page - 1) * $num_on_page;
$searchName = null;
$url_params = '';
if (isset($_GET['search'])) {
$searchName = $_GET['search'];
if (strlen($url_params) > 0) {
$url_params = $url_params . "&";
}
$url_params = $url_params . "search=" . $_GET['search'];
}
$blocksCount = Block::count($searchName);
$all_pages = ceil($blocksCount / $num_on_page);
if ($blocksCount > 0) {
$blocksList = Block::search($searchName, $from, $num_on_page);
?>
<div class="jw__NB">
<?php
$numFrom = $from + 1;
$numTo = (($from + $num_on_page) >= $blocksCount) ? $blocksCount : ($from + $num_on_page);
echo '<div style="margin: 13px 35px; font-weight: bold;"><span style="float: left; line-height: 2;">Показаны записи ' . $numFrom . '-' . $numTo . ' из ' . $blocksCount . '</span>';
if ($willBeRun && !$isImporterActive) {
echo '<span style = "color: red;float: right;" >Обновление с Flatshop будет запущено в ближайшие 5 минут.</span>';
}
if ($isImporterActive) {
echo '<span style="color: red;float: right;">В данный момент работает обновление с Flatshop.</span>';
}
if (!$willBeRun && !$isImporterActive) {
echo '<a style="float: right;" href="/admin/blocks.php?run=1" class="medium-button allFromFlatShop">Обновить все с FlatShop</a>';
}
echo '</div>';
?>
<div class="jw__NB__flat-list">
<table>
<thead>
<tr>
<th>ID</th>
<th>Название</th>
<th>Комиссия (значение у блока)</th>
<th>Комиссия (используемая в расчетах)</th>
<th>Количество апартаментов</th>
<th>&nbsp;</th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
<?php
$num = 1;
foreach ($blocksList as $block) {
echo '<tr ';
if ($num % 2 > 0) {
echo 'style="background-color: #f9f9f9;"';
}
echo '>';
echo '<td>' . $block->id . '</td>';
echo '<td><a href="/admin/blockEdit.php?id=' . $block->id . '" title="Редактировать">' . $block->name . '</a></td>';
echo '<td>' . number_format($block->fee, 2, ',', ' ') . '</td>';
echo '<td>' . number_format($block->getCalculatedFee(), 2, ',', ' ') . '</td>';
echo '<td>' . $block->apartmentsCount . '</td>';
echo '<td>';
echo '<a href="javascript:void(0);" data-id="'. $block->id . '" class="update-block-from-fs">Обновить с FlatShop</a>';
echo '</td>';
echo '<td style="width: 26px; height: 26px;"><div id="action_loader_' . $block->id . '" style="width: 26px; height:26px; background:url(/images/ajax_preloader.gif) no-repeat center center; background-size: 26px 26px; display: none;"></div></td>';
echo '</tr>';
$num++;
}
?>
</tbody>
</table>
</div>
<?php
echo '<div class="f-system_pagination" style="padding: 20px 20px 0 20px;"><ul class="pagination">';
if ($all_pages > 1) {
num_of_pages($page, $all_pages, $url_params);
}
echo '</ul></div>';
?>
</div>
<? } else echo "<div class='empty-block'><h1><i class='ti-na'></i></h1><h2>Комплексов не найдено</h2></div>" ?>
<div class="clear"></div>
</div>
<script src="/js/admin-edit.js?t=<?php echo ceil(microtime(true)); ?>"></script>
<?php
require_once($_SERVER['DOCUMENT_ROOT'] . "/templates/footer-admin.php");
?>