-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
1,352 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
session_start(); | ||
require_once('../require/config.php'); | ||
require_once '../lib/Examples/jpgraph/jpgraph.php'; | ||
require_once '../lib/Examples/jpgraph/jpgraph_line.php'; | ||
|
||
// Запрос к функции | ||
$sql = "CALL get_booking_counts_by_hotel()"; | ||
$stmt = $connect->prepare($sql); | ||
$stmt->execute(); | ||
|
||
$results = $stmt->fetchAll(PDO::FETCH_ASSOC); | ||
|
||
$hotels = array(); | ||
$counts = array(); | ||
|
||
// Перебор результатов и добавление данных в массивы | ||
foreach ($results as $row) { | ||
$hotels[] = $row["Название"]; | ||
$counts[] = $row["Количество_Человек"]; | ||
} | ||
|
||
// Находим индекс отеля с наибольшим количеством людей | ||
if (!empty($counts)) { | ||
$maxIndex = array_search(max($counts), $counts); | ||
$mostPopularHotel = $hotels[$maxIndex]; | ||
$mostPeople = $counts[$maxIndex]; | ||
} | ||
|
||
$graph = new Graph(700,400); | ||
$graph->SetScale("textlin"); | ||
|
||
$theme_class=new UniversalTheme; | ||
|
||
$graph->SetTheme($theme_class); | ||
$graph->img->SetAntiAliasing(false); | ||
$graph->title->Set('Распределение проживающих в базах отдыха Омутнинска'); | ||
$graph->SetBox(false); | ||
|
||
$graph->SetMargin(100,100,40,40); | ||
|
||
$graph->img->SetAntiAliasing(); | ||
|
||
$graph->yaxis->HideZeroLabel(); | ||
$graph->yaxis->HideLine(false); | ||
$graph->yaxis->HideTicks(false,false); | ||
$graph->yaxis->scale->SetAutoMin(0); | ||
|
||
$graph->xgrid->Show(); | ||
$graph->xgrid->SetLineStyle("solid"); | ||
$graph->xaxis->SetTickLabels($hotels); | ||
$graph->xgrid->SetColor('#E3E3E3'); | ||
|
||
$p1 = new LinePlot($counts); | ||
$graph->Add($p1); | ||
$p1->SetColor("#6495ED"); | ||
$p1->SetLegend('Количество проживающих'); | ||
|
||
$graph->legend->SetFrameWeight(1); | ||
|
||
$filename = './graph/graph_' . uniqid() . '.png'; | ||
$graph->Stroke($filename); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
<?php | ||
session_start(); | ||
require_once('../require/session_vars.php'); | ||
require_once('../require/config.php'); | ||
|
||
if (isset($_COOKIE['login'])) { | ||
$email = $_COOKIE['login']; | ||
$parts = explode('@', $email); | ||
|
||
// Берем первую часть массива, которая будет до '@' | ||
$username = $parts[0]; | ||
} else{ | ||
header("Location: registration.php"); | ||
exit; } | ||
|
||
$sql = "CALL GetBookingDetailsByEmail(:email)"; | ||
$stmt = $connect->prepare($sql); | ||
$stmt->bindParam(':email', $_COOKIE['login'], PDO::PARAM_STR); | ||
$stmt->execute(); | ||
$results = $stmt->fetchAll(PDO::FETCH_ASSOC); | ||
|
||
|
||
// Шаг 1: Найти ID учетной записи по логину | ||
$stmt = $connect->prepare("SELECT ID_Учетной_записи FROM учетные_данные WHERE Email = :email"); | ||
$stmt->bindParam(':email', $email); | ||
$stmt->execute(); | ||
$row = $stmt->fetch(PDO::FETCH_ASSOC); | ||
$accountId = $row['ID_Учетной_записи']; | ||
|
||
$sql = "SELECT GetUserDetailsByID(:userID) AS user_data"; | ||
$stmt = $connect->prepare($sql); | ||
$stmt->bindParam(':userID', $accountId, PDO::PARAM_INT); | ||
$stmt->execute(); | ||
$result = $stmt->fetch(PDO::FETCH_ASSOC); | ||
|
||
// Парсим результат | ||
$userData = $result['user_data']; | ||
if ($userData!=''){ | ||
list($firstname, $lastname, $patronymic, $phone) = explode(', ', $userData); | ||
} | ||
else{ | ||
$firstname=""; | ||
$lastname=""; | ||
$patronymic=""; | ||
$phone=""; | ||
} | ||
|
||
|
||
if ($_COOKIE['employeeMode']=='true'){ | ||
$conn = new mysqli($host,$user, $password, $db); | ||
// для получения статистики бронирований | ||
$sql_bookings = "SELECT getTotalBookings() AS total_booking"; | ||
$result_bookings = $conn->query($sql_bookings); | ||
$total_bookings = $result_bookings->fetch_assoc()['total_booking']; | ||
|
||
//для получения информации о популярных услугах | ||
$sql_services = $connect->prepare("SELECT * FROM популярные_услуги"); | ||
$sql_services->execute(); | ||
$result_services = $sql_services->fetchAll(PDO::FETCH_ASSOC); | ||
|
||
$sql_income = "SELECT getTotalIncome() AS total"; | ||
$result_income = $conn->query($sql_income); | ||
$total_income = $result_income->fetch_assoc()['total']; | ||
|
||
// Выполнение запроса для извлечения данных сотрудника по ID_Пользователя | ||
$sql_employee = $connect->prepare("SELECT * FROM сотрудники с LEFT JOIN пользователи п ON п.ID_Пользователя = с.ID_Пользователя | ||
LEFT JOIN базы_отдыха бо ON бо.ID_Места = с.ID_Места | ||
WHERE п.ID_Учетной_записи = :accountId LIMIT 1"); | ||
$sql_employee->bindParam(':accountId', $accountId, PDO::PARAM_INT); | ||
$sql_employee->execute(); | ||
$employee_data = $sql_employee->fetch(PDO::FETCH_ASSOC); | ||
|
||
} | ||
|
||
if (isset($_POST["save_button"])){ | ||
$_SESSION["firstname"] = isset($_POST["firstname"]) ? $_POST["firstname"] : ""; | ||
$_SESSION["lastname"] = isset($_POST["lastname"]) ? $_POST["lastname"] : ""; | ||
$_SESSION["patronymic"] = isset($_POST["patronymic"]) ? $_POST["patronymic"] : ""; | ||
$_SESSION["phone"] = isset($_POST["phone"]) ? $_POST["phone"] : ""; | ||
|
||
$firstname = $_POST["firstname"]; | ||
$lastname = $_POST["lastname"]; | ||
$patronymic = $_POST["patronymic"]; | ||
$phone = $_POST["phone"]; | ||
if ($userData!=''){ | ||
$stmt = $connect->prepare("UPDATE пользователи SET Имя = :firstname, Фамилия = :lastname, Отчество = :patronymic, Телефон = :phone WHERE ID_Учетной_записи = :accountId LIMIT 1"); | ||
$stmt->bindParam(':firstname', $firstname); | ||
$stmt->bindParam(':lastname', $lastname); | ||
$stmt->bindParam(':patronymic', $patronymic); | ||
$stmt->bindParam(':phone', $phone); | ||
$stmt->bindParam(':accountId', $accountId); | ||
$stmt->execute(); | ||
} | ||
else{ | ||
$sql = "INSERT INTO пользователи (Имя, Фамилия, Отчество, Телефон, ID_Учетной_записи) VALUES (:firstname,:lastname, :patronymic, :phone, :accountId)"; | ||
$stmt = $connect->prepare($sql); | ||
$stmt->bindParam(':firstname', $firstname); | ||
$stmt->bindParam(':lastname', $lastname); | ||
$stmt->bindParam(':patronymic', $patronymic); | ||
$stmt->bindParam(':phone', $phone); | ||
$stmt->bindParam(':accountId', $accountId); | ||
$stmt->execute(); | ||
} | ||
|
||
if ($_COOKIE['employeeMode']=='true'){ | ||
if ($employee_data['Должность']!=""){ | ||
$_SESSION["staff"] = isset($_POST["staff"]) ? $_POST["staff"] : ""; | ||
$_SESSION["start_work"] = isset($_POST["start_work"]) ? $_POST["start_work"] : ""; | ||
$_SESSION["work"] = isset($_POST["work"]) ? $_POST["work"] : ""; | ||
|
||
$staff = $_POST["staff"]; | ||
$start_work = $_POST["start_work"]; | ||
$work = $_POST["work"]; | ||
|
||
$stmt = $connect->prepare(" | ||
UPDATE сотрудники с | ||
JOIN пользователи п ON п.ID_Пользователя = с.ID_Пользователя | ||
SET с.Должность = :staff, с.Дата_приема_на_работу = :start_work, с.ID_Места = :work | ||
WHERE п.ID_Учетной_записи = :accountId | ||
"); | ||
$stmt->bindParam(':staff', $staff); | ||
$stmt->bindParam(':start_work', $start_work); | ||
$stmt->bindParam(':work', $employee_data['ID_Места']); | ||
$stmt->bindParam(':accountId', $accountId); | ||
$stmt->execute(); | ||
} | ||
else{ | ||
|
||
|
||
$sql = "INSERT INTO сотрудники (Должность, Дата_приема_на_работу, ID_Места, ID_Пользователя) VALUES (:staff, :start_work, :work, :user_id)"; | ||
$stmt = $connect->prepare($sql); | ||
$stmt->bindParam(':staff', $staff); | ||
$stmt->bindParam(':start_work', $start_work); | ||
$stmt->bindParam(':work', $work); | ||
$stmt->bindParam(':user_id', $employee_data['ID_Пользователя']); | ||
$stmt->execute(); | ||
} | ||
} | ||
} | ||
|
||
if (isset($_POST["admin"])){ | ||
header("Location: admin.php"); | ||
exit; | ||
} | ||
|
||
|
||
if (isset($_POST["exit_button"])){ | ||
setcookie('auth', '', time() - 3600, '/'); | ||
setcookie('login', '', time() - 3600, '/'); | ||
setcookie('adminMode', '', time() - 3600, '/'); | ||
setcookie('employeeMode', '', time() - 3600, '/'); | ||
|
||
// Очистка всех данных сессии | ||
session_unset(); | ||
session_destroy(); | ||
|
||
header("Location: ../index.php"); | ||
exit; } | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
session_start(); | ||
require_once('../require/session_vars.php'); | ||
require_once('../require/config.php'); | ||
|
||
if (!isset($_COOKIE['adminMode']) || $_COOKIE['adminMode'] !== 'true') { | ||
header('Location: ../index.php'); // Перенаправление на главную страницу, если пользователь не администратор | ||
exit(); | ||
} | ||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['table'])) { | ||
$_SESSION['selected_table'] = $_POST['table']; | ||
} | ||
|
||
// Получение списка таблиц | ||
$stmt = $connect->prepare("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_SCHEMA = ?"); | ||
$stmt->execute([$connect->query("SELECT DATABASE()")->fetchColumn()]); | ||
$tables = $stmt->fetchAll(PDO::FETCH_COLUMN); | ||
|
||
function getPrimaryKey($connect, $table) { | ||
$stmt = $connect->prepare(" | ||
SELECT COLUMN_NAME | ||
FROM INFORMATION_SCHEMA.COLUMNS | ||
WHERE TABLE_SCHEMA = DATABASE() | ||
AND TABLE_NAME = :table | ||
AND COLUMN_KEY = 'PRI' | ||
"); | ||
$stmt->bindParam(':table', $table, PDO::PARAM_STR); | ||
$stmt->execute(); | ||
$result = $stmt->fetch(PDO::FETCH_ASSOC); | ||
return $result ? $result['COLUMN_NAME'] : null; | ||
} | ||
|
||
// Определение текущей таблицы | ||
$table = isset($_POST['table']) ? $_POST['table'] : null; | ||
|
||
if (isset($_POST['table'])) { | ||
$table = $_POST['table']; | ||
$primaryKey = getPrimaryKey($connect, $table); | ||
|
||
if ($primaryKey) { | ||
$stmt = $connect->prepare("SELECT * FROM $table"); | ||
$stmt->execute(); | ||
$result = $stmt->fetchAll(PDO::FETCH_ASSOC); | ||
} | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
session_start(); | ||
$auth = isset($_COOKIE['auth']) && $_COOKIE['auth'] === 'true'; | ||
$adminMode = isset($_COOKIE['adminMode']) && $_COOKIE['adminMode'] === 'true'; | ||
|
||
if ($auth) { | ||
$str_login = 'Вы зашли как '.$_COOKIE['login']; | ||
} else { | ||
$str_login = 'Пользователь не авторизован'; | ||
} | ||
|
||
if (isset($_POST["exit_button"])){ | ||
setcookie('auth', '', time() - 3600, '/'); | ||
setcookie('login', '', time() - 3600, '/'); | ||
|
||
// Очистка всех данных сессии | ||
session_unset(); | ||
// Уничтожение сессии | ||
session_destroy(); | ||
|
||
header("Location: ../index.php"); | ||
exit; } | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?php | ||
|
||
$file_path = "../".$_POST["firstname_input"].'_'. date("d-m-Y") . ".txt"; | ||
$data = "Поздравляем Вас, ".$_POST["firstname_input"].", с успешным бронированием базы отдыха:\n"; | ||
$data .= $hotel['Название'].' в номере '.$room['Название_номера']; | ||
$data .=" \nПо адресу ".$hotel['Адрес']; | ||
$data .=" \nВаш заезд начинается ".$_SESSION['arrivalDate']." и заканчивается ".$_SESSION['departureDate']."\n"; | ||
$data .= $_SESSION['chosen_food_type'].', '.$foodCost.'₽ на '.$days.' дней'; | ||
$data .= "\nВыбранные услуги на ".$ServicesCost."₽ : ".implode(', ', $_SESSION['service']); | ||
$data .=" \nКоличество дней: ".$days ; | ||
$data .= "\nОбщая стоимость заказа составляет: ".$cost." рублей"; | ||
$data .= "\n\n Приятного отдыха!"; | ||
file_put_contents($file_path, $data); | ||
|
||
|
||
// Определяем адрес получателя и отправителя | ||
$to = $_POST["input_email"]; | ||
$from = "[email protected]"; | ||
|
||
// Формируем тему письма | ||
$subject = $_POST["firstname_input"].'_'. date("d-m-Y") . ".txt"; | ||
|
||
// Получаем содержимое изображения | ||
$image_path = "../img/".$hotel['Фото']; | ||
$image_content = file_get_contents($image_path); | ||
|
||
// Кодируем изображение в base64 | ||
$image_base64 = base64_encode($image_content); | ||
|
||
// Формируем тег <img> с закодированным изображением | ||
$image_tag = '<img src="data:image/jpeg;base64,' . $image_base64 . '" class="image" style="margin-right: 10px; width: 250px; hidth: 300px; ">'; | ||
|
||
// Тело письма | ||
$message = '<html><body>'; | ||
$message .= '<center>Уважаемый(ая) '.$_POST["firstname_input"].' '.$_POST["lastname_input"].'!</center><br>'; | ||
$message .= '<table cellpadding="0" cellspacing="0" border="0" style="border-collapse: collapse;">'; | ||
$message .= '<tr>'; | ||
$message .= '<td style="padding-right: 300px;">'.$image_tag.'</td>'; | ||
$message .= '<td>'; | ||
$message .= 'Вы забронировали номер в базе отдыха:<br>'; | ||
$message .= '<strong> '.$hotel['Название'].'</strong>, номер '.$room['Название_номера'].'<br>'; | ||
$message .= 'В путёвку входят: <strong>'.$_SESSION['chosen_food_type'].'</strong><br>'; | ||
if (!empty($_SESSION['service'])) { | ||
$selected_services = $_SESSION['service']; // Предполагается, что это массив | ||
$message .= '<strong>Дополнительные услуги:</strong>'; | ||
$message .= '<ul>'; | ||
foreach ($selected_services as $service) { | ||
$message .= '<li>' . htmlspecialchars($service) . '</li>'; | ||
} | ||
$message .= '</ul>'; | ||
} | ||
$message .= '</td>'; | ||
$message .= '</tr>'; | ||
$message .= '</table>'; | ||
$message .= 'Полная стоимость бронирования: '.$cost.' рублей.<br>'; | ||
|
||
$message .= '<small>Почти настоящая компания.</small>'; | ||
$message .= '</body></html>'; | ||
|
||
// Добавляем вложение | ||
$file_content = file_get_contents($file_path); | ||
$encoded_file_content = chunk_split(base64_encode($file_content)); | ||
$attachment = "--boundary\r\n"; | ||
$attachment .= "Content-Type: application/octet-stream; name=\"" . basename($file_path) . "\"\r\n"; | ||
$attachment .= "Content-Transfer-Encoding: base64\r\n"; | ||
$attachment .= "Content-Disposition: attachment; filename=\"" . basename($file_path) . "\"\r\n"; | ||
$attachment .= "\r\n"; | ||
$attachment .= $encoded_file_content . "\r\n"; | ||
|
||
// Добавляем текстовое сообщение | ||
$body = "--boundary\r\n"; | ||
$body .= "Content-Type: text/html; charset=utf-8\r\n"; | ||
$body .= "Content-Transfer-Encoding: 8bit\r\n"; | ||
$body .= "\r\n"; | ||
$body .= $message . "\r\n"; | ||
$body .= $attachment; | ||
$body .= "--boundary--\r\n"; | ||
|
||
// Заголовки письма | ||
$headers = "From: $from\r\n"; | ||
$headers .= "Reply-To: [email protected]\r\n"; | ||
$headers .= "MIME-Version: 1.0\r\n"; | ||
$headers .= "Content-Type: multipart/mixed; boundary=\"boundary\"\r\n"; | ||
|
||
// Отправляем письмо | ||
mail($to, $subject, $body, $headers); | ||
// Сохранение данных в файл | ||
file_put_contents($file_path, $data); | ||
|
||
?> |
Oops, something went wrong.