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>
<span class="nav__name">Сущности</span>
</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
use App\Services\{Router, Auth};
use \App\Services\{Auth, DB, Date};
use \App\Models\User;
$user = new \App\Models\User(Auth::userid());
@ -13,30 +16,87 @@ if (!isset($_GET['type']) || $_GET['type'] != 'Photo') {
<!DOCTYPE html>
<html lang="ru">
<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(); } ?>">
<script src="/static/js/notie.js<?php if (NGALLERY['root']['cloudflare-caching'] === true) { echo '?'.time(); } ?>"></script>
<link rel="stylesheet" href="/static/css/notie.css<?php if (NGALLERY['root']['cloudflare-caching'] === true) {
echo '?' . time();
} ?>">
<script src="/static/js/notie.js<?php if (NGALLERY['root']['cloudflare-caching'] === true) {
echo '?' . time();
} ?>"></script>
<script>
notie.setOptions({
transitionCurve: 'cubic-bezier(0.2, 0, 0.2, 1)'
});
var Notify = {
noty: function(status, text) {
notie.setOptions({
transitionCurve: 'cubic-bezier(0.2, 0, 0.2, 1)'
});
var Notify = {
noty: function(status, text) {
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>
<body>
<div class="container">
<?=\App\Controllers\AdminController::loadMenu();?>
<?=\App\Controllers\AdminController::loadContent();?>
<h1><b>Сущности</b></h1>
<a href="?type=EntityCreate" class="btn btn-primary">Создать</a>
</div>
<div class="container">
<?= \App\Controllers\AdminController::loadMenu(); ?>
<?= \App\Controllers\AdminController::loadContent(); ?>
<h1><b>Сущности</b></h1>
<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>

View file

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

View file

View file