Joywork/admin/reservations.php

292 lines
11 KiB
PHP
Raw 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/document/target/DocTarget.php';
include $_SERVER['DOCUMENT_ROOT'] . '/import/reservation/state/IReservationState.php';
include $_SERVER['DOCUMENT_ROOT'] . '/import/reservation/state/BaseState.php';
include $_SERVER['DOCUMENT_ROOT'] . '/import/reservation/state/StateNew.php';
include $_SERVER['DOCUMENT_ROOT'] . '/import/reservation/state/StateCancel.php';
include $_SERVER['DOCUMENT_ROOT'] . '/import/reservation/state/StateWork.php';
include $_SERVER['DOCUMENT_ROOT'] . '/import/reservation/state/StateDelete.php';
include $_SERVER['DOCUMENT_ROOT'] . '/import/reservation/state/StateBought.php';
include $_SERVER['DOCUMENT_ROOT'] . '/import/reservation/Reservation.php';
include $_SERVER['DOCUMENT_ROOT'] . '/import/reservation/ReservationStateButtonsColumn.php';
?>
<div class="main-title">
<h1>Брони пользователей</h1>
</div>
<div class="users fr__users" style="margin-right: 20px;">
<?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 = '';
$reservationsCount = Reservation::count(null);
$all_pages = ceil($reservationsCount / $num_on_page);
if ($reservationsCount > 0) {
$reservationsList = Reservation::search(null, $from, $num_on_page);
?>
<div class="jw__NB">
<?php
$numFrom = $from + 1;
$numTo = (($from + $num_on_page) >= $reservationsCount) ? $reservationsCount : ($from + $num_on_page);
echo '<div style="margin: 13px 35px; font-weight: bold;">Показаны записи ' . $numFrom . '-' . $numTo . ' из ' . $reservationsCount . '</div>'
?>
<div class="jw__NB__flat-list">
<table>
<thead>
<tr>
<th>Заметка</th>
<th>Инфо</th>
<th>ID</th>
<th>Дата брони</th>
<th>Ф.И.О. клиента</th>
<th>Статус брони</th>
<th>Пользователь</th>
<th>Цена кв при 100% опл</th>
<th>Базовая стоимость</th>
<th>Ожидаемая комиссия</th>
<th>&nbsp;</th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
<?php
$num = 1;
foreach ($reservationsList as $reservation) {
$reservationUser = new User;
$reservationUser->get($reservation->user_id);
echo '<tr ';
if ($num % 2 > 0) {
echo 'style="background-color: #f9f9f9;"';
}
$fee = (float)$reservation->fee;
$feeFormated = number_format($reservation->fee, 2, ',', ' ');
$money = number_format(round($reservation->full_price*$fee / 100), 0, ',', ' ');
echo '>';
echo '<td><a href="#" class="admin-note-reservation" data-id="' . $reservation->id . '" title="Заметка"><i class="ti-plus"></i></a></td>';
echo '<td><a href="#" class="admin-view-reservation" data-id="' . $reservation->id . '" title="Просмотр"><i class="ti-search"></i></a></td>';
echo '<td>' . $reservation->id . '</td>';
echo '<td>' . $reservation->created_at . '</td>';
echo '<td>' . $reservation->getFullname() . '</td>';
echo '<td>' . $reservation->getStateName() . '</td>';
echo '<td><a href="#" class="reservationUser" data-id="' . $reservationUser->id . '">' . $reservationUser->fio . '</a></td>';
echo '<td style="white-space: nowrap;">' . number_format($reservation->full_price, 0, ',', ' ') . '</td>';
echo '<td style="white-space: nowrap;">' . number_format($reservation->base_price, 0, ',', ' ') . '</td>';
echo '<td>' . sprintf('%s (%s%%)', $money, $feeFormated) . '</td>';
echo '<td>' . (new ReservationStateButtonsColumn())->renderDataCellContent($reservation) . '</td>';
echo '<td style="width: 26px; height: 26px;"><div id="action_loader_' . $reservation->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>
<div class="full_modal-bg" id="flat-booking__bg" style="display: none;">
<span class="pseudo-link closer event-modal-closer">
<i class="ti-close"></i>
</span>
<div class="full_modal flat__modal flat-booking" id="flat-booking" style="display: none;">
</div>
</div>
<div class="full_modal-bg" id="flat__bg" style="display: none;">
<span class="pseudo-link closer-flat event-modal-closer"
style="z-index: 999999" onclick="$('#flat').hide(10); $('#flat__bg').hide(10);">
<i class="ti-close"></i>
</span>
<div class="full_modal flat__modal" id="flat" style="display: none;">
<div class="flat__inner">
<div class="flat__top">
<h2 id="flat_modal_title">Квартира №2562</h2>
</div>
<div class="jw-tabs" id="flatModalTabs">
<ul class="tabs__caption">
<li><span>Квартира</span></li>
<li><span>О комплексе</span></li>
<li><span>Ипотека</span></li>
<li><span>Документы</span></li>
<li><span>Условия покупки</span></li>
</ul>
<div>
<div class="tabs__content" style="display: none;" id="flat_info_tab">
</div>
<div class="tabs__content" style="display: block;" id="block_info_tab">
</div>
<div class="tabs__content" style="display: none;" id="banks_info_tab">
</div>
<div class="tabs__content" style="display: none;" id="docs_info_tab">
</div>
<div class="tabs__content" style="display: none;" id="conditions_info_tab">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="f__modal-bg" id="user_data_bg" style="display: none;">
<div class="f__modal sign" id="user_data" style="display: none;padding-bottom: 0;">
<span class="pseudo-link closer" onclick="hideUserDataMessage(); return false;"><i class="ti-close"></i></span>
<div class="f-col">
<div class="f-col-9">
<h1>Данные пользователя</h1>
</div>
<div class="f-col-3">&nbsp;</div>
<div class="clear"></div>
</div>
<div class="f-col">
<div class="f-col-3">&nbsp;</div>
<div class="f-col-6">
<div class="bg-danger" style="font-size:1.2em; border-radius:5px; text-align:center;" id="user_data_block">
</div>
<div style="width:240px; margin:20px auto;text-align: center;">
<a href="#" onclick="hideUserDataMessage(); return false;" class="fr-btn medium-button">Закрыть</a>
</div>
</div>
<div class="f-col-3">&nbsp;</div>
<div class="clear"></div>
</div>
</div>
</div>
<div class="f__modal-bg" id="note_data_bg" style="display: none;">
<div class="f__modal sign" id="note_data" style="display: none;padding-bottom: 0;">
<span class="pseudo-link closer" onclick="hideNoteDataMessage(); return false;"><i class="ti-close"></i></span>
<div class="f-col">
<div class="f-col-9">
<h1>Заметка</h1>
</div>
<div class="f-col-3">&nbsp;</div>
<div class="clear"></div>
</div>
<div class="f-col">
<div class="f-col-12">
<div class="form-block">
<div class="label" style="font-weight: bold; width: 30%;">Текст заметки:</div>
<div class="clear"></div>
</div>
<div class="form-block">
<div class="inputs">
<textarea rows="8" style="width: 490px;" name="reservation_note" id="reservation_note"></textarea>
</div>
<div class="clear"></div>
</div>
</div>
<div class="clear"></div>
</div>
<div class="f-col">
<div class="f-col-12">
<div style="width:240px; margin:20px auto;text-align: center; height: 45px;">
<a href="#" id="saveReservationNote" class="fr-btn medium-button">Сохранить</a>
</div>
</div>
<div class="clear"></div>
</div>
</div>
</div>
<script src="/js/admin-edit.js?t=<?php echo ceil(microtime(true)); ?>"></script>
<script type="text/javascript" src="/js/fotorama.js"></script>
<script type="text/javascript" src="https://api-maps.yandex.ru/2.0/?load=package.standard&lang=ru-RU"></script>
<?php
require_once($_SERVER['DOCUMENT_ROOT'] . "/templates/footer-admin.php");
?>