96 lines
4.8 KiB
PHP
96 lines
4.8 KiB
PHP
|
|
<?php
|
||
|
|
require_once($_SERVER['DOCUMENT_ROOT'] . "/config.php");
|
||
|
|
|
||
|
|
if ($_SESSION['id'] && isset($_SESSION['superadmin']) && $_POST['id']) {
|
||
|
|
|
||
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/import/obj/ImportRecord.php';
|
||
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/import/reservation/state/IReservationState.php';
|
||
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/import/reservation/Reservation.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/ApartmentHistory.php';
|
||
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/import/obj/ImportRecord.php';
|
||
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/import/document/target/DocTarget.php';
|
||
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/import/obj/Apartment.php';
|
||
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/import/obj/Block.php';
|
||
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/import/ImporterService.php';
|
||
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/import/obj/Building.php';
|
||
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/import/obj/RoomType.php';
|
||
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/import/obj/DecorationType.php';
|
||
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/import/obj/FlatType.php';
|
||
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/import/obj/Builder.php';
|
||
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/import/obj/Region.php';
|
||
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/import/obj/BlockSubway.php';
|
||
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/import/helper/Date.php';
|
||
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/import/Clock/Clock.php';
|
||
|
|
include $_SERVER['DOCUMENT_ROOT'] . '/import/Clock/RealtimeClock.php';
|
||
|
|
|
||
|
|
$reservation = Reservation::findOne($_POST['id']);
|
||
|
|
|
||
|
|
if ($reservation) {
|
||
|
|
|
||
|
|
$reservation->remove();
|
||
|
|
|
||
|
|
$user = new User;
|
||
|
|
|
||
|
|
$user->get($reservation->user_id);
|
||
|
|
|
||
|
|
$apartmentHistory = new ApartmentHistory();
|
||
|
|
$storedData = $apartmentHistory->getData($reservation->id);
|
||
|
|
|
||
|
|
$apartment = unserialize($storedData['apartment']);
|
||
|
|
$block = unserialize($storedData['block']);
|
||
|
|
$building = unserialize($storedData['building']);
|
||
|
|
$roomType = unserialize($storedData['roomType']);
|
||
|
|
$builder = unserialize($storedData['builder']);
|
||
|
|
|
||
|
|
$f1 = file("https://joywork.ru/template_mail/reservation_status.html");
|
||
|
|
$text = implode("", $f1);
|
||
|
|
|
||
|
|
$text = str_replace("<%apartment_number%>", $reservation->apartment_number, $text);
|
||
|
|
$text = str_replace("<%user_name%>", $user->fio, $text);
|
||
|
|
$text = str_replace("<%reservation_status%>", $reservation->getStateName(), $text);
|
||
|
|
$text = str_replace("<%room_type%>", $roomType->name, $text);
|
||
|
|
$text = str_replace("<%space_total%>", $apartment->space_total, $text);
|
||
|
|
$text = str_replace("<%flat_floor%>", $apartment->flat_floor, $text);
|
||
|
|
$text = str_replace("<%discount_price%>", number_format($reservation->full_price, 0, ',', ' '), $text);
|
||
|
|
$text = str_replace("<%base_price%>", number_format($reservation->base_price, 0, ',', ' '), $text);
|
||
|
|
$text = str_replace("<%block_name%>", $block->name, $text);
|
||
|
|
$text = str_replace("<%building_line%>", $building->line, $text);
|
||
|
|
$text = str_replace("<%building_corp%>", $building->corp, $text);
|
||
|
|
$text = str_replace("<%building_deadline%>", Date::getFormatedEndingPeriod($building->deadline), $text);
|
||
|
|
$text = str_replace("<%building_floors%>", $building->floors, $text);
|
||
|
|
$text = str_replace("<%block_address%>", $block->address, $text);
|
||
|
|
$text = str_replace("<%builder_name%>", $builder->name, $text);
|
||
|
|
$text = str_replace("<%reservation_client_name%>", $reservation->getFullname(), $text);
|
||
|
|
$text = str_replace("<%reservation_client_phone%>", $reservation->phone, $text);
|
||
|
|
|
||
|
|
$style = "";
|
||
|
|
switch( $reservation->status ) {
|
||
|
|
case 1:
|
||
|
|
$style = "background: #d0d0d0; color: #757575;";
|
||
|
|
break;
|
||
|
|
case 2:
|
||
|
|
$style = "background: #ffc107; color: #ffffff;";
|
||
|
|
break;
|
||
|
|
case 3:
|
||
|
|
$style = "background: #d0d0d0; color: #757575;";
|
||
|
|
break;
|
||
|
|
case 4:
|
||
|
|
$style = "background: #4caf50;color: #ffffff;";
|
||
|
|
break;
|
||
|
|
case 5:
|
||
|
|
$style = "background: #d0d0d0; color: #757575;";
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
|
||
|
|
$text = str_replace("<%reservation_status_style%>", $style, $text);
|
||
|
|
|
||
|
|
mailClientFromJoywork($user->email, "Изменен статус брони", $text);
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|