entities admin

This commit is contained in:
themohooks 2024-09-15 21:31:44 +03:00
parent ac1e0770b1
commit 732c5dc854
5 changed files with 107 additions and 40 deletions

View file

@ -66,6 +66,10 @@ body {
<i class="bx bx-package nav__icon"></i> <i class="bx bx-package nav__icon"></i>
<span class="nav__name">Сущности</span> <span class="nav__name">Сущности</span>
</a> </a>
<a href="/admin?type=Models" class="nav__link">
<i class="bx bx-data nav__icon"></i>
<span class="nav__name">База моделей</span>
</a>

View file

@ -1,5 +1,8 @@
<?php <?php
use App\Services\{Router, Auth};
use \App\Services\{Auth, DB, Date};
use \App\Models\User;
$user = new \App\Models\User(Auth::userid()); $user = new \App\Models\User(Auth::userid());
@ -13,8 +16,12 @@ if (!isset($_GET['type']) || $_GET['type'] != 'Photo') {
<!DOCTYPE html> <!DOCTYPE html>
<html lang="ru"> <html lang="ru">
<script src="https://code.jquery.com/jquery-3.7.1.js"></script> <script src="https://code.jquery.com/jquery-3.7.1.js"></script>
<link rel="stylesheet" href="/static/css/notie.css<?php if (NGALLERY['root']['cloudflare-caching'] === true) { echo '?'.time(); } ?>"> <link rel="stylesheet" href="/static/css/notie.css<?php if (NGALLERY['root']['cloudflare-caching'] === true) {
<script src="/static/js/notie.js<?php if (NGALLERY['root']['cloudflare-caching'] === true) { echo '?'.time(); } ?>"></script> echo '?' . time();
} ?>">
<script src="/static/js/notie.js<?php if (NGALLERY['root']['cloudflare-caching'] === true) {
echo '?' . time();
} ?>"></script>
<script> <script>
notie.setOptions({ notie.setOptions({
@ -25,17 +32,70 @@ var Notify = {
if (status == 'danger') status = 'error'; if (status == 'danger') status = 'error';
return notie.alert({ type: status, text: text }) return notie.alert({
type: status,
text: text
})
}, },
} }
</script> </script>
<body> <body>
<div class="container"> <div class="container">
<?= \App\Controllers\AdminController::loadMenu(); ?> <?= \App\Controllers\AdminController::loadMenu(); ?>
<?= \App\Controllers\AdminController::loadContent(); ?> <?= \App\Controllers\AdminController::loadContent(); ?>
<h1><b>Сущности</b></h1> <h1><b>Сущности</b></h1>
<a href="?type=EntityCreate" class="btn btn-primary">Создать</a> <a href="?type=EntityCreate" class="btn btn-primary">Создать</a>
<div class="p20w" style="display:block">
<table class="table">
<tbody>
<tr>
<th width="100">ID</th>
<th width="50%">Название</th>
<th>Действия</th>
</tr>
<?php
$photos = DB::query('SELECT * FROM entities ORDER BY id DESC');
foreach ($photos as $p) {
echo ' <tr id="pht' . $p['id'] . '" class="' . $color . '">
<td>
'.$p['id'].'
</td>
<td>
'.$p['title'].'
</td>
<td class="c">
';
echo '<a href="/admin?type=EntityEdit&id=' . $p['id'] . '&mod=1" class="btn btn-primary">Редактировать</a>
<a data-bs-toggle="modal" data-bs-target="#declinePhotoModal' . $p['id'] . '" href="#" class="btn btn-danger">Удалить</a>
</td>';
echo '
</tr>
';
}
?>
</tbody>
</table>
</div><br>
<?php
$entities = DB::query('SELECT * FROM entities');
foreach ($entities as $e) {
}
?>
</div> </div>

View file

@ -1,4 +1,8 @@
<?php <?php
use \App\Services\{Auth, DB};
use \App\Models\User;
if (isset($_POST['create'])) { if (isset($_POST['create'])) {
$postData = $_POST; $postData = $_POST;
@ -23,8 +27,8 @@ if (isset($_POST['create'])) {
$jsonResult = json_encode($result, JSON_PRETTY_PRINT); $jsonResult = json_encode($result, JSON_PRETTY_PRINT);
header('Content-Type: application/json'); DB::query('INSERT INTO entities VALUES (\'0\', :title, :createdate, :sampledata, :color)', array(':title' => $_POST['title'], ':createdate' => time(), ':sampledata' => $jsonResult, ':color' => $_POST['color']));
echo $jsonResult; header('Location: /admin?type=Entities');
} }
?> ?>
<h1><b>Создание сущности</b></h1> <h1><b>Создание сущности</b></h1>
@ -32,11 +36,11 @@ if (isset($_POST['create'])) {
<div class="mb-3"> <div class="mb-3">
<label for="exampleFormControlInput1" class="form-label">Название</label> <label for="exampleFormControlInput1" class="form-label">Название</label>
<input type="text" class="form-control" id="exampleFormControlInput1" placeholder="Вагон метро"> <input type="text" name="title" class="form-control" id="exampleFormControlInput1" placeholder="Вагон метро">
</div> </div>
<div class="mb-3"> <div class="mb-3">
<label for="exampleFormControlInput1" class="form-label">Цвет</label> <label for="exampleFormControlInput1" class="form-label">Цвет</label>
<input type="text" class="form-control" id="exampleFormControlInput1" placeholder="#FFFFFF"> <input type="text" name="color" class="form-control" id="exampleFormControlInput1" placeholder="#FFFFFF">
</div> </div>
<p>Вводимые переменные</p> <p>Вводимые переменные</p>
<div class="alert alert-dark" role="alert"> <div class="alert alert-dark" role="alert">
@ -110,8 +114,7 @@ document.getElementById('addButton').addEventListener('click', function() {
<option value="1">Да</option> <option value="1">Да</option>
<option value="2">Нет</option> <option value="2">Нет</option>
</select> </select>
</div>` </div>`;
;
// Добавляем новый элемент в #entityform // Добавляем новый элемент в #entityform
document.getElementById('entityform').insertAdjacentHTML('beforeend', newElement); document.getElementById('entityform').insertAdjacentHTML('beforeend', newElement);

View file

View file