Joywork/admin/builders.php

171 lines
4.9 KiB
PHP
Raw Permalink Normal View History

2026-05-22 20:21:54 +02:00
<?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("Доступ запрещён!");
}
require_once($_SERVER['DOCUMENT_ROOT'] . "/templates/header-admin.php");
include $_SERVER['DOCUMENT_ROOT'] . '/import/obj/ImportRecord.php';
include $_SERVER['DOCUMENT_ROOT'] . '/import/obj/Builder.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'];
}
$buildersCount = Builder::countActive($searchName);
$all_pages = ceil($buildersCount / $num_on_page);
if ($buildersCount > 0) {
$buildersList = Builder::searchActive($searchName, $from, $num_on_page);
?>
<div class="jw__NB">
<?php
$numFrom = $from + 1;
$numTo = (($from + $num_on_page) >= $buildersCount) ? $buildersCount : ($from + $num_on_page);
echo '<div style="margin: 13px 35px; font-weight: bold;">Показаны записи ' . $numFrom . '-' . $numTo . ' из ' . $buildersCount . '</div>'
?>
<div class="jw__NB__flat-list">
<table>
<thead>
<tr>
<th></th>
<th>ID</th>
<th>Название застройщика</th>
<th>Комиссия</th>
<th>Комиссия переуступок</th>
<th>Срок выплаты комиссионных застройщиком</th>
<th></th>
</tr>
</thead>
<tbody>
<?php
$num = 1;
foreach ($buildersList as $builder) {
$note = "";
if ($builder->note) {
$note = $builder->note;
}
echo '<tr ';
if ($num % 2 > 0) {
echo 'style="background-color: #f9f9f9;"';
}
echo '>';
echo '<td><i class="ti-info-alt" title="' . str_replace("<br>", "\n", $note) . '"></i></td>';
echo '<td>' . $builder->id . '</td>';
echo '<td>' . $builder->name . '</td>';
echo '<td>' . number_format($builder->fee, 2, ',', ' ') . '</td>';
echo '<td>' . number_format($builder->discount_fee, 2, ',', ' ') . '</td>';
echo '<td>' . $builder->pay_period . '</td>';
echo '<td><a href="/admin/builderEdit.php?id=' . $builder->id . '" title="Редактировать"><i class="ti-pencil"></i></a></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>
<?php
require_once($_SERVER['DOCUMENT_ROOT'] . "/templates/footer-admin.php");
?>