#3: new passes type, user applications page, bug fixes
This commit is contained in:
parent
8072bccfb1
commit
438dd59762
44
index.js
44
index.js
@ -481,6 +481,50 @@ app.get("/applications", checkAuthorization, async (req, res) => {
|
||||
});
|
||||
});
|
||||
|
||||
app.get("/myapplications", checkAuthorization, async (req, res) => {
|
||||
const token = req.cookies.token;
|
||||
|
||||
var options = {
|
||||
method: "POST",
|
||||
url: process.env.API_SERVER + "/forms/getmyapplications",
|
||||
headers: {
|
||||
Authorization: req.cookies.token,
|
||||
},
|
||||
};
|
||||
|
||||
axios
|
||||
.request(options)
|
||||
.then(function (response) {
|
||||
const authorizationHeader = response.headers["authorization"];
|
||||
|
||||
res.cookie("token", authorizationHeader, {
|
||||
maxAge: twelveHoursInSeconds * 1000,
|
||||
});
|
||||
|
||||
var templateData = {
|
||||
API_SERVER: process.env.API_SERVER,
|
||||
User: response.data.userData,
|
||||
Role: response.data.role,
|
||||
Applications: response.data.applications,
|
||||
Total: response.data.totalCount,
|
||||
};
|
||||
|
||||
const source = fs.readFileSync(
|
||||
"static/templates/account/myapplications.html",
|
||||
"utf8"
|
||||
);
|
||||
const template = handlebars.compile(source);
|
||||
const resultT = template(templateData);
|
||||
res.send(resultT);
|
||||
})
|
||||
.catch(function (error) {
|
||||
if (error.response) {
|
||||
console.error("Ошибка при отправке GET-запроса:", error);
|
||||
res.status(500).send("Произошла ошибка при выполнении запроса.");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
app.get("/passes", checkAuthorization, async (req, res) => {
|
||||
const token = req.cookies.token;
|
||||
|
||||
|
@ -20,7 +20,7 @@ const createTable = () => {
|
||||
type.textContent = application.type;
|
||||
row.appendChild(type);
|
||||
const worker = document.createElement("td");
|
||||
worker.textContent = application.worker;
|
||||
worker.innerHTML = application.worker;
|
||||
row.appendChild(worker);
|
||||
const legal = document.createElement("td");
|
||||
legal.innerHTML = application.legal;
|
||||
|
141
static/scripts/myapplications-table.js
Normal file
141
static/scripts/myapplications-table.js
Normal file
@ -0,0 +1,141 @@
|
||||
const createTable = () => {
|
||||
const table = document.getElementById("applicationsTable");
|
||||
const tbody = table.querySelector("tbody");
|
||||
|
||||
// Очищаем таблицу
|
||||
tbody.innerHTML = "";
|
||||
|
||||
applications.forEach((application) => {
|
||||
const row = document.createElement("tr");
|
||||
row.setAttribute("onclick", `openApplication(${application.id});`);
|
||||
|
||||
// Добавляем ячейки с данными
|
||||
const id = document.createElement("td");
|
||||
id.textContent = application.id;
|
||||
row.appendChild(id);
|
||||
const status = document.createElement("td");
|
||||
status.textContent = application.status;
|
||||
row.appendChild(status);
|
||||
const type = document.createElement("td");
|
||||
type.textContent = application.type;
|
||||
row.appendChild(type);
|
||||
const worker = document.createElement("td");
|
||||
worker.innerHTML = application.worker;
|
||||
row.appendChild(worker);
|
||||
const legal = document.createElement("td");
|
||||
legal.innerHTML = application.legal;
|
||||
row.appendChild(legal);
|
||||
const date = document.createElement("td");
|
||||
const rawDate = new Date(application.date);
|
||||
const formattedDate = `${rawDate.getDate().toString().padStart(2, "0")}/${(
|
||||
rawDate.getMonth() + 1
|
||||
)
|
||||
.toString()
|
||||
.padStart(2, "0")}/${rawDate.getFullYear()}`;
|
||||
date.textContent = formattedDate;
|
||||
row.appendChild(date);
|
||||
|
||||
const finaldate = document.createElement("td");
|
||||
if (application.finaldate) {
|
||||
const rawFinalDate = new Date(application.finaldate);
|
||||
const formattedfinalDate = `${rawFinalDate
|
||||
.getDate()
|
||||
.toString()
|
||||
.padStart(2, "0")}/${(rawFinalDate.getMonth() + 1)
|
||||
.toString()
|
||||
.padStart(2, "0")}/${rawFinalDate.getFullYear()}`;
|
||||
finaldate.textContent = formattedfinalDate;
|
||||
} else {
|
||||
finaldate.textContent = "";
|
||||
}
|
||||
row.appendChild(finaldate);
|
||||
const car = document.createElement("td");
|
||||
if (application.car) {
|
||||
let carText = application.car.replace(/"/g, '"');
|
||||
carText = JSON.parse(carText).join(", ");
|
||||
car.textContent = carText;
|
||||
}
|
||||
row.appendChild(car);
|
||||
|
||||
tbody.appendChild(row);
|
||||
});
|
||||
};
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
createTable();
|
||||
});
|
||||
|
||||
function getCookie(name) {
|
||||
var cookies = document.cookie.split(";");
|
||||
for (var i = 0; i < cookies.length; i++) {
|
||||
var cookie = cookies[i].trim();
|
||||
if (cookie.startsWith(name + "=")) {
|
||||
return cookie.substring(name.length + 1);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function requestUpdate() {
|
||||
document.getElementById("applicationsTable").style.filter =
|
||||
"brightness(0.85)";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append(
|
||||
"page",
|
||||
parseInt(document.getElementById("page-number").textContent)
|
||||
);
|
||||
|
||||
const requestOptions = {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: getCookie("token"),
|
||||
},
|
||||
body: formData,
|
||||
};
|
||||
|
||||
fetch(API_SERVER + "/forms/getmyapplications", requestOptions)
|
||||
.then((response) => {
|
||||
document.getElementById("applicationsTable").style.filter =
|
||||
"brightness(1)";
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
} else {
|
||||
console.error("Ошибка при отправке POST запроса.");
|
||||
return "Ошибка при отправке запроса.";
|
||||
}
|
||||
})
|
||||
.then((data) => {
|
||||
applications.splice(0, applications.length);
|
||||
|
||||
applications.push(
|
||||
...data.applications.map((item) => ({
|
||||
id: item.id,
|
||||
status: item.Статус,
|
||||
type: item.Вид_заявки,
|
||||
worker: item.Работник,
|
||||
date: item.Дата_заявки,
|
||||
finaldate: item.Дата_решения,
|
||||
legal: item.Организация,
|
||||
car: item.Авто_гос_номер,
|
||||
}))
|
||||
);
|
||||
|
||||
createTable();
|
||||
|
||||
totalMax = Math.ceil(data.totalCount / 15);
|
||||
|
||||
if (totalMax === 0) {
|
||||
totalMax = 1;
|
||||
}
|
||||
|
||||
var currentPage = parseInt(pageNumberInput.textContent, 10);
|
||||
if (currentPage > totalMax) {
|
||||
pageNumberInput.textContent = totalMax;
|
||||
requestUpdate();
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Ошибка при отправке запроса:", error);
|
||||
});
|
||||
}
|
@ -29,7 +29,7 @@ const createTable = () => {
|
||||
type.textContent = pass.type;
|
||||
row.appendChild(type);
|
||||
const worker = document.createElement("td");
|
||||
worker.textContent = pass.name;
|
||||
worker.innerHTML = pass.name;
|
||||
row.appendChild(worker);
|
||||
const legal = document.createElement("td");
|
||||
legal.innerHTML = pass.legal;
|
||||
|
@ -26,10 +26,10 @@ const createTable = () => {
|
||||
date.textContent = formattedDate;
|
||||
row.appendChild(date);
|
||||
const type = document.createElement("td");
|
||||
type.textContent = pass.type;
|
||||
type.innerHTML = pass.type;
|
||||
row.appendChild(type);
|
||||
const object = document.createElement("td");
|
||||
object.textContent = pass.object;
|
||||
object.innerHTML = pass.object;
|
||||
row.appendChild(object);
|
||||
const editdate = document.createElement("td");
|
||||
if (pass.editdate) {
|
||||
@ -46,7 +46,7 @@ const createTable = () => {
|
||||
}
|
||||
row.appendChild(editdate);
|
||||
const executor = document.createElement("td");
|
||||
executor.textContent = pass.executor;
|
||||
executor.innerHTML = pass.executor;
|
||||
row.appendChild(executor);
|
||||
|
||||
tbody.appendChild(row);
|
||||
|
@ -20,13 +20,13 @@ const createTable = () => {
|
||||
id.textContent = user.id;
|
||||
row.appendChild(id);
|
||||
const surname = document.createElement("td");
|
||||
surname.textContent = user.surname;
|
||||
surname.innerHTML = user.surname;
|
||||
row.appendChild(surname);
|
||||
const name = document.createElement("td");
|
||||
name.textContent = user.name;
|
||||
name.innerHTML = user.name;
|
||||
row.appendChild(name);
|
||||
const secondname = document.createElement("td");
|
||||
secondname.textContent = user.secondname;
|
||||
secondname.innerHTML = user.secondname;
|
||||
row.appendChild(secondname);
|
||||
const role = document.createElement("td");
|
||||
if (user.role) {
|
||||
@ -36,10 +36,10 @@ const createTable = () => {
|
||||
}
|
||||
row.appendChild(role);
|
||||
const phone = document.createElement("td");
|
||||
phone.textContent = user.phone;
|
||||
phone.innerHTML = user.phone;
|
||||
row.appendChild(phone);
|
||||
const email = document.createElement("td");
|
||||
email.textContent = user.email;
|
||||
email.innerHTML = user.email;
|
||||
row.appendChild(email);
|
||||
const sub = document.createElement("td");
|
||||
sub.textContent = user.sub;
|
||||
|
@ -77,6 +77,24 @@
|
||||
<h1>Настройки</h1>
|
||||
<h2>Изменить информацию профиля</h2>
|
||||
</div>
|
||||
<div onclick="location.href='/myapplications'" class="hub-element">
|
||||
<div class="icon">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="32" fill="none" viewBox="0 0 20 32">
|
||||
<g clip-path="url(#a)">
|
||||
<path fill="#000" fill-opacity=".85" d="M19.424 8.188v17.507c0 2.425-1.19 3.626-3.58 3.626H3.58C1.19 29.32 0 28.12 0 25.695V8.188c0-2.425 1.19-3.626 3.58-3.626h.153a2.71 2.71 0 0 0-.014.288v1.213c0 .123.007.243.023.358h-.07c-1.2 0-1.813.646-1.813 1.79v17.46c0 1.155.612 1.79 1.813 1.79h12.08c1.2 0 1.813-.635 1.813-1.79V8.212c0-1.144-.612-1.79-1.813-1.79h-.07a2.5 2.5 0 0 0 .024-.358V4.85c0-.098-.005-.195-.015-.288h.153c2.39 0 3.58 1.2 3.58 3.626Z"/>
|
||||
<path fill="#000" fill-opacity=".85" d="M6.144 7.206h7.136c.67 0 1.074-.427 1.074-1.143V4.85c0-.716-.404-1.143-1.074-1.143h-1.062c-.08-1.305-1.166-2.367-2.506-2.367-1.34 0-2.425 1.062-2.506 2.367H6.144c-.67 0-1.074.427-1.074 1.143v1.213c0 .716.404 1.143 1.074 1.143Zm3.568-2.402a1.013 1.013 0 0 1-1.005-1.005c0-.566.45-1.016 1.005-1.016.554 0 1.005.45 1.005 1.016 0 .543-.45 1.005-1.005 1.005ZM4.62 22.069h5.127a.72.72 0 0 0 .716-.716.712.712 0 0 0-.716-.716H4.619a.722.722 0 0 0-.727.716.73.73 0 0 0 .727.716Zm0-4.319h10.185a.725.725 0 0 0 .727-.728.712.712 0 0 0-.727-.704H4.619a.712.712 0 0 0-.727.704c0 .404.323.728.727.728Zm0-4.1h10.185a.73.73 0 0 0 .727-.716.74.74 0 0 0-.727-.728H4.619a.74.74 0 0 0-.727.728.73.73 0 0 0 .727.716Z"/>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="a">
|
||||
<path fill="#fff" d="M0 0h19.424v32H0z"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
|
||||
</div>
|
||||
<h1>Мои заявки</h1>
|
||||
<h2>Отслеживание ваших заявок на пропуска</h2>
|
||||
</div>
|
||||
|
||||
{{#if (eq Role 'Дирекция')}}
|
||||
<div onclick="location.href='/users'" class="hub-element">
|
||||
|
@ -144,8 +144,8 @@
|
||||
<input type="date" id="editdate-input" required>
|
||||
</div>
|
||||
<div class="input-area">
|
||||
<label for="editdate-input">Действие до*</label>
|
||||
<input type="date" id="edittodate-input" required>
|
||||
<label for="editdate-input">Действие до</label>
|
||||
<input type="date" id="edittodate-input">
|
||||
</div>
|
||||
<div class="input-area">
|
||||
<label for="editfinaldate-input">Дата решения</label>
|
||||
@ -253,6 +253,7 @@
|
||||
const name = $('#editname-input').val();
|
||||
const legal = $('#editlegal-input').val();
|
||||
const date = $('#editdate-input').val();
|
||||
const todate = $('#edittodate-input').val();
|
||||
const finaldate = $('#editfinaldate-input').val();
|
||||
const decision = $('#editdecision-input').val();
|
||||
const carnumber = $('#editcarnumber-input').val();
|
||||
@ -271,7 +272,7 @@
|
||||
"Content-Type": "application/json",
|
||||
Authorization: getCookie("token"),
|
||||
},
|
||||
body: JSON.stringify({ id, status, name, legal, date, finaldate, decision, carnumber, carbrand, carmodel, carcolor, tmcname, tmcunit, tmcquantity, additional })
|
||||
body: JSON.stringify({ id, status, name, legal, date, todate, finaldate, decision, carnumber, carbrand, carmodel, carcolor, tmcname, tmcunit, tmcquantity, additional })
|
||||
});
|
||||
if (response.status === 201) {
|
||||
location.reload();
|
||||
@ -314,7 +315,7 @@
|
||||
$("#deleteApplication-button").attr("onclick", `deleteApplication(${id})`);
|
||||
$("#makePass-button").attr("onclick", `makePass(${id})`);
|
||||
|
||||
if (data.data.Вид_заявки === "Временный") {
|
||||
if (data.data.Вид_заявки === "Временный" || data.data.Вид_заявки === "Разовый") {
|
||||
$("#car-inputs").css("display", "none");
|
||||
$("#tmc-inputs").css("display", "none");
|
||||
} else if (data.data.Вид_заявки === "Автомобильный") {
|
||||
@ -402,7 +403,13 @@
|
||||
} else {
|
||||
$("#editfinaldate-input").val("");
|
||||
}
|
||||
$("#edittodate-input").val("");
|
||||
|
||||
if (data.data.Действие_до) {
|
||||
formatDateForDateInput(data.data.Действие_до, "edittodate-input");
|
||||
} else {
|
||||
$("#edittodate-input").val("");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -443,7 +450,7 @@
|
||||
|
||||
|
||||
if (!todate || !date || !name ) {
|
||||
alert("Пожалуйста, заполните все поля со звездочками.")
|
||||
alert("Пожалуйста, заполните все поля.")
|
||||
$('#makePass-button').removeClass('inactive');
|
||||
return;
|
||||
}
|
||||
|
@ -50,12 +50,16 @@
|
||||
<h1>Новая заявка на пропуск</h1>
|
||||
<div class="radio-inputs">
|
||||
<label class="radio">
|
||||
<input autocomplete="off" type="radio" id="temp-radio" name="form-type" value="temp" checked>
|
||||
<span class="name">Временный пропуск</span>
|
||||
<input autocomplete="off" type="radio" id="onetime-radio" name="form-type" value="onetime" checked>
|
||||
<span class="name">Разовый</span>
|
||||
</label>
|
||||
<label class="radio">
|
||||
<input autocomplete="off" type="radio" id="temp-radio" name="form-type" value="temp">
|
||||
<span class="name">Временный</span>
|
||||
</label>
|
||||
<label class="radio">
|
||||
<input autocomplete="off" type="radio" id="car-radio" name="form-type" value="car">
|
||||
<span class="name">Автомобильный пропуск</span>
|
||||
<span class="name">Автомобильный</span>
|
||||
</label>
|
||||
<label class="radio">
|
||||
<input autocomplete="off" type="radio" id="tmc-radio" name="form-type" value="tmc">
|
||||
@ -254,6 +258,28 @@
|
||||
$('#send-button').removeClass('inactive');
|
||||
}
|
||||
}
|
||||
if (document.getElementById('onetime-radio').checked) {
|
||||
type = "Разовый";
|
||||
// Отправляем запрос на сервер для авторизации
|
||||
const response = await fetch("{{API_SERVER}}/passes/newform", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: getCookie("token"),
|
||||
},
|
||||
body: JSON.stringify({ formrole, passtext, type, fullnames, legalname, date })
|
||||
});
|
||||
if (response.status === 201) {
|
||||
const data = await response.json();
|
||||
alert("Ваша заявка принята к рассмотрению!")
|
||||
|
||||
window.location.href = "/";
|
||||
$('#send-button').removeClass('inactive');
|
||||
} else {
|
||||
alert("Произошла ошибка при попытке отправить заявку");
|
||||
$('#send-button').removeClass('inactive');
|
||||
}
|
||||
}
|
||||
if (document.getElementById('car-radio').checked) {
|
||||
type = "Автомобильный";
|
||||
|
||||
@ -338,7 +364,7 @@
|
||||
} else if (this.value === "tmc") {
|
||||
carInputs.style.display = 'none';
|
||||
tmcInputs.style.display = 'flex';
|
||||
} else if (this.value === "temp") {
|
||||
} else if (this.value === "temp" || this.value === "onetime") {
|
||||
carInputs.style.display = 'none';
|
||||
tmcInputs.style.display = 'none';
|
||||
}
|
||||
|
352
static/templates/account/myapplications.html
Normal file
352
static/templates/account/myapplications.html
Normal file
@ -0,0 +1,352 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="../styles/main.css">
|
||||
<script src="../scripts/jquery.min.js"></script>
|
||||
<script src="../scripts/helpPopup.js"></script>
|
||||
<title>Мои заявки</title>
|
||||
<script>
|
||||
const API_SERVER = "{{API_SERVER}}";
|
||||
let applications = [
|
||||
{{#each Applications}}
|
||||
{
|
||||
id: {{this.id}},
|
||||
status: "{{this.Статус}}",
|
||||
type: "{{this.Вид_заявки}}",
|
||||
worker: "{{this.Работник}}",
|
||||
date: "{{this.Дата_заявки}}",
|
||||
finaldate: "{{this.Дата_решения}}",
|
||||
legal: "{{this.Организация}}",
|
||||
car: "{{this.Авто_гос_номер}}",
|
||||
},
|
||||
{{/each}}
|
||||
];
|
||||
</script>
|
||||
<script src="../scripts/myapplications-table.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<a href="/account"><h1>Система управления пользователями</h1></a>
|
||||
<nav>
|
||||
<div class="dropdown">
|
||||
<a class="help-button" onclick="toggleDropdown('dropdownHelp-1')">Техническая поддержка</a>
|
||||
<div id="dropdownHelp-1" class="dropdown-help">
|
||||
<a href="tel:83477527706">8 (34775) 2-77-06</a>
|
||||
<a href="tel:89174023516">8 (917) 402-35-16</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dropdown">
|
||||
<a class="help-button" onclick="toggleDropdown('dropdownHelp-2')">Инструкции</a>
|
||||
<div id="dropdownHelp-2" class="dropdown-help dropdown-manual">
|
||||
<a href="/docs/manual.pdf" target="_blank">Текст</a>
|
||||
<a href="https://drive.google.com/file/d/1CxrAgr2brQclZqtbbreSUU9tN-jsNTwf/view?usp=sharing" target="_blank">Видео</a>
|
||||
</div>
|
||||
</div>
|
||||
<a href="/account">Профиль</a>
|
||||
{{#if (eq Role 'legal')}}
|
||||
<span>{{User.Наименование}}</span>
|
||||
{{else}}
|
||||
<span>{{User.Фамилия}} {{User.Имя}} {{User.Отчество}}</span>
|
||||
{{/if}}
|
||||
<a class="exit-button" href="/logout"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="16" fill="none" viewBox="0 0 20 16">
|
||||
<path fill="#6B7A99" d="m4.016 7.13 2.608-2.606-1.226-1.226L.696 8l4.702 4.702 1.226-1.226L4.016 8.87h4.858V7.131H4.016ZM8.874.179v6.953h5.215V8.87H8.874v6.953h10.43V.178H8.873Z"/>
|
||||
</svg>
|
||||
</a>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<div id="applicationsWrapper" class="table-wrapper">
|
||||
<table id="applicationsTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Статус</th>
|
||||
<th>Вид</th>
|
||||
<th>ФИО</th>
|
||||
<th>Организация</th>
|
||||
<th>Дата пропуска</th>
|
||||
<th>Дата решения</th>
|
||||
<th>Автомобиль</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- Сюда будут добавляться строки таблицы -->
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="pagination">
|
||||
<div id="left-slider" onclick="decrementPage()">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="11" height="19" fill="none" viewBox="0 0 11 19">
|
||||
<path fill="#000" fill-opacity=".75" d="M0 9.495c0 .273.101.514.315.722l8.92 8.477a.981.981 0 0 0 .73.295c.585 0 1.035-.427 1.035-.995 0-.285-.124-.525-.304-.711L2.508 9.495l8.188-7.789c.18-.186.304-.437.304-.71C11 .425 10.55 0 9.965 0c-.292 0-.54.098-.73.284L.314 8.773A.955.955 0 0 0 0 9.495Z"/>
|
||||
</svg>
|
||||
</div>
|
||||
<div id="page-number">1</div>
|
||||
<div id="right-slider" onclick="incrementPage()">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="11" height="19" fill="none" viewBox="0 0 11 19">
|
||||
<path fill="#000" fill-opacity=".75" d="M11 9.495a.967.967 0 0 0-.326-.722L1.766.284A1.062 1.062 0 0 0 1.024 0C.45 0 0 .427 0 .995c0 .274.112.525.292.711l8.189 7.789-8.189 7.788c-.18.186-.292.426-.292.71 0 .57.45.996 1.024.996.292 0 .54-.098.742-.295l8.908-8.477c.213-.208.326-.449.326-.722Z"/>
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form id="editApplicationForm">
|
||||
<input type="text" id="editapplicationid-input" hidden>
|
||||
<input type="text" id="editapplicationtype-input" hidden>
|
||||
<div id="editapplication-form-popup-bg" class="form-popup-bg not-main" >
|
||||
<div class="form-container">
|
||||
<div id="btnCloseForm" class="close-button"><svg onclick="closeForm();" id="btnCloseFormSvg" xmlns="http://www.w3.org/2000/svg" width="14" height="14" fill="none" viewBox="0 0 14 14">
|
||||
<path fill="#0050CF" fill-rule="evenodd" d="M14 1.41 12.59 0 7 5.59 1.41 0 0 1.41 5.59 7 0 12.59 1.41 14 7 8.41 12.59 14 14 12.59 8.41 7 14 1.41Z" clip-rule="evenodd"/>
|
||||
</svg>
|
||||
</div>
|
||||
<h1>Заявка на <span id="editApplication"></span> пропуск</h1>
|
||||
<br>
|
||||
|
||||
<div class="input-area">
|
||||
<label for="editauthor-input">Автор</label>
|
||||
<input type="text" id="editauthor-input" readonly>
|
||||
</div>
|
||||
|
||||
<div class="input-area">
|
||||
<label for="editstatus-input">Статус</label>
|
||||
<input type="text" id="editstatus-input" readonly>
|
||||
</div>
|
||||
|
||||
<div class="input-area">
|
||||
<label for="editname-input">ФИО*</label>
|
||||
<input type="text" id="editname-input" required readonly>
|
||||
</div>
|
||||
<div class="input-area">
|
||||
<label for="editlegal-input">Организация</label>
|
||||
<input type="text" id="editlegal-input" readonly>
|
||||
</div>
|
||||
|
||||
<div class="input-area">
|
||||
<label for="editdate-input">Дата выдачи</label>
|
||||
<input type="date" id="editdate-input" required readonly>
|
||||
</div>
|
||||
<div class="input-area">
|
||||
<label for="editdate-input">Действие до</label>
|
||||
<input type="date" id="edittodate-input" required readonly>
|
||||
</div>
|
||||
<div class="input-area">
|
||||
<label for="editfinaldate-input">Дата решения</label>
|
||||
<input type="date" id="editfinaldate-input" readonly>
|
||||
</div>
|
||||
<div class="input-area">
|
||||
<label for="editdecision-input">Решение</label>
|
||||
<input type="text" id="editdecision-input" readonly>
|
||||
</div>
|
||||
|
||||
<div style="display: none;" class="inputs" id="car-inputs">
|
||||
<ul id="carlist"></ul>
|
||||
<input type="text" id="editcarnumber-input" hidden readonly>
|
||||
<input type="text" id="editcarbrand-input" hidden readonly>
|
||||
<input type="text" id="editcarmodel-input" hidden readonly>
|
||||
<input type="text" id="editcarcolor-input" hidden readonly>
|
||||
</div>
|
||||
|
||||
<div style="display: none;" class="inputs" id="tmc-inputs">
|
||||
<ul id="tmclist"></ul>
|
||||
<input type="text" id="edittmcname-input" hidden readonly>
|
||||
<input type="text" id="edittmcunit-input" hidden readonly>
|
||||
<input type="text" id="edittmcquantity-input" hidden readonly>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="input-area">
|
||||
<label for="editadditional-input">Дополнительно</label>
|
||||
<textarea id="editadditional-input" readonly></textarea>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
|
||||
var pageNumberInput = document.getElementById('page-number');
|
||||
var totalMax = Math.ceil({{Total}} / 15);
|
||||
|
||||
function decrementPage() {
|
||||
var currentPage = parseInt(pageNumberInput.textContent, 10);
|
||||
if (currentPage > 1) {
|
||||
pageNumberInput.textContent = currentPage - 1;
|
||||
requestUpdate();
|
||||
} else {
|
||||
requestUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
function incrementPage() {
|
||||
var currentPage = parseInt(pageNumberInput.textContent, 10);
|
||||
|
||||
if (currentPage === totalMax || currentPage > totalMax) {
|
||||
pageNumberInput.textContent = totalMax;
|
||||
requestUpdate();
|
||||
}
|
||||
if (currentPage < totalMax) {
|
||||
pageNumberInput.textContent = currentPage + 1;
|
||||
requestUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<script>
|
||||
function closeForm() {
|
||||
$('.form-popup-bg').removeClass('is-visible');
|
||||
}
|
||||
|
||||
$(document).ready(function($) {
|
||||
|
||||
$('#addUser').on('click', function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
$('#adduser-form-popup-bg').addClass('is-visible');
|
||||
});
|
||||
|
||||
$('#editapplication-form-popup-bg').on('click', function(event) {
|
||||
if ($(event.target).is('#editapplication-form-popup-bg') || $(event.target).is('#btnCloseForm')) {
|
||||
event.preventDefault();
|
||||
$(this).removeClass('is-visible');
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function openApplication(id) {
|
||||
const requestOptions = {
|
||||
method: "GET",
|
||||
headers: {
|
||||
Authorization: getCookie("token"),
|
||||
},
|
||||
};
|
||||
|
||||
fetch(API_SERVER + "/forms/application?id=" + id, requestOptions)
|
||||
.then((response) => {
|
||||
if (response.ok) {
|
||||
$("#editapplication-form-popup-bg").addClass("is-visible");
|
||||
return response.json();
|
||||
} else {
|
||||
console.error("Ошибка при отправке POST запроса.");
|
||||
return "Ошибка при отправке запроса.";
|
||||
}
|
||||
})
|
||||
.then((data) => {
|
||||
|
||||
$("#editapplicationid-input").val(id);
|
||||
|
||||
$("#editApplication").html(data.data.Вид_заявки);
|
||||
|
||||
if (data.data.Вид_заявки === "Временный" || data.data.Вид_заявки === "Разовый") {
|
||||
$("#car-inputs").css("display", "none");
|
||||
$("#tmc-inputs").css("display", "none");
|
||||
} else if (data.data.Вид_заявки === "Автомобильный") {
|
||||
$("#car-inputs").css("display", "flex");
|
||||
$("#tmc-inputs").css("display", "none");
|
||||
} else if (data.data.Вид_заявки === "ТМЦ") {
|
||||
$("#car-inputs").css("display", "none");
|
||||
$("#tmc-inputs").css("display", "flex");
|
||||
}
|
||||
|
||||
$("#editauthor-input").val(data.data.Автор);
|
||||
|
||||
$("#editname-input").val(data.data.Работник);
|
||||
$("#editlegal-input").val(data.data.Организация);
|
||||
$("#editstatus-input").val(data.data.Статус);
|
||||
$("#editdecision-input").val(data.data.Решение);
|
||||
|
||||
$("#editcarnumber-input").val(data.data.Авто_гос_номер);
|
||||
$("#editcarbrand-input").val(data.data.Авто_марка);
|
||||
$("#editcarmodel-input").val(data.data.Авто_модель);
|
||||
$("#editcarcolor-input").val(data.data.Авто_цвет);
|
||||
|
||||
$("#edittmcname-input").val(data.data.Наименование);
|
||||
$("#edittmcunit-input").val(data.data.Единица_измерения);
|
||||
$("#edittmcquantity-input").val(data.data.Количество);
|
||||
|
||||
if (data.data.Вид_заявки === "ТМЦ") {
|
||||
var tmcnames = JSON.parse(data.data.Наименование);
|
||||
var tmcunits = JSON.parse(data.data.Единица_измерения);
|
||||
var tmcquantitys = JSON.parse(data.data.Количество);
|
||||
|
||||
var tmclist = "";
|
||||
|
||||
for (var i = 0; i < tmcnames.length; i++) {
|
||||
tmclist += "<li><span style='font-weight: 600;'>Позиция " + (i + 1) + ":</span> <br>" +
|
||||
"Наименование ТМЦ - " + tmcnames[i] + "<br>" +
|
||||
"Единица измерения - " + tmcunits[i] + "<br>" +
|
||||
"Количество - " + tmcquantitys[i] +
|
||||
"</li>";
|
||||
}
|
||||
|
||||
$("#tmclist").html(tmclist);
|
||||
}
|
||||
|
||||
|
||||
if (data.data.Вид_заявки === "Автомобильный") {
|
||||
var carnumbers = JSON.parse(data.data.Авто_гос_номер);
|
||||
var carbrands = JSON.parse(data.data.Авто_марка);
|
||||
var carmodels = JSON.parse(data.data.Авто_модель);
|
||||
var carcolors = JSON.parse(data.data.Авто_цвет);
|
||||
|
||||
var carlist = "";
|
||||
|
||||
for (var i = 0; i < carnumbers.length; i++) {
|
||||
carlist += "<li><span style='font-weight: 600;'>Авто " + (i + 1) + ":</span> <br>" +
|
||||
"Номер - " + carnumbers[i] + "<br>" +
|
||||
"Марка - " + carbrands[i] + "<br>" +
|
||||
"Модель - " + carmodels[i] + "<br>" +
|
||||
"Цвет - " + carcolors[i] +
|
||||
"</li>";
|
||||
}
|
||||
|
||||
$("#carlist").html(carlist);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$("#editadditional-input").val(data.data.Дополнение);
|
||||
$("#editapplicationtype-input").val(data.data.Вид_заявки);
|
||||
|
||||
|
||||
function formatDateForDateInput(dateString, inputId) {
|
||||
const date = new Date(dateString);
|
||||
const year = date.getFullYear();
|
||||
const month = (date.getMonth() + 1).toString().padStart(2, '0');
|
||||
const day = date.getDate().toString().padStart(2, '0');
|
||||
const formattedDate = `${year}-${month}-${day}`;
|
||||
|
||||
document.getElementById(inputId).value = formattedDate;
|
||||
}
|
||||
|
||||
formatDateForDateInput(data.data.Дата_заявки, "editdate-input");
|
||||
if (data.data.Дата_решения) {
|
||||
formatDateForDateInput(data.data.Дата_решения, "editfinaldate-input");
|
||||
} else {
|
||||
$("#editfinaldate-input").val("");
|
||||
}
|
||||
if (data.data.Действие_до) {
|
||||
formatDateForDateInput(data.data.Действие_до, "edittodate-input");
|
||||
} else {
|
||||
$("#edittodate-input").val("");
|
||||
}
|
||||
|
||||
|
||||
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Ошибка при отправке запроса:", error);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
@ -33,7 +33,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<a href="/account"><h1>Система управления заявками на пропуска</h1></a>
|
||||
<a href="/account"><h1>Система управления пропусками</h1></a>
|
||||
<nav>
|
||||
<div class="dropdown">
|
||||
<a class="help-button" onclick="toggleDropdown('dropdownHelp-1')">Техническая поддержка</a>
|
||||
@ -120,6 +120,7 @@
|
||||
<div class="input-area">
|
||||
<label for="newPassType">Вид пропуска*</label>
|
||||
<select name="pass-type" id="newPassType">
|
||||
<option value="Разовый">Разовый пропуск</option>
|
||||
<option value="Временный">Временный пропуск</option>
|
||||
<option value="Автомобильный">Автомобильный пропуск</option>
|
||||
<option value="ТМЦ">Ввоз-Вывоз ТМЦ</option>
|
||||
@ -428,7 +429,7 @@
|
||||
const tmcInputs = document.getElementById('tmc-inputs');
|
||||
|
||||
typeSelect.addEventListener('change', function() {
|
||||
if (this.value === "Временный" || this.value === "Материальный") {
|
||||
if (this.value === "Временный" || this.value === "Материальный" || this.value === "Разовый") {
|
||||
carInputs.style.display = 'none';
|
||||
tmcInputs.style.display = 'none';
|
||||
} else if (this.value === "Автомобильный") {
|
||||
@ -461,7 +462,7 @@
|
||||
const additional = $('#additional-input').val();
|
||||
|
||||
|
||||
if ($('#newPassType').val() === "Временный" || $('#newPassType').val() === "Материальный") {
|
||||
if ($('#newPassType').val() === "Временный" || $('#newPassType').val() === "Материальный" || $('#newPassType').val() === "Разовый") {
|
||||
// Отправляем запрос на сервер для авторизации
|
||||
const response = await fetch("{{API_SERVER}}/passes/newpass", {
|
||||
method: "POST",
|
||||
@ -558,7 +559,7 @@
|
||||
const additional = $('#editadditional-input').val();
|
||||
|
||||
|
||||
if ($('#editpasstype-input').val() === "Временный" || $('#editpasstype-input').val() === "Материальный") {
|
||||
if ($('#editpasstype-input').val() === "Временный" || $('#editpasstype-input').val() === "Материальный" || $('#editpasstype-input').val() === "Разовый") {
|
||||
// Отправляем запрос на сервер для авторизации
|
||||
const response = await fetch("{{API_SERVER}}/passes/update", {
|
||||
method: "PUT",
|
||||
@ -670,7 +671,7 @@
|
||||
|
||||
$("#deletePass-button").attr("onclick", `deletePass(${id})`);
|
||||
|
||||
if (data.data.Вид_пропуска === "Временный" || data.data.Вид_пропуска === "Материальный") {
|
||||
if (data.data.Вид_пропуска === "Временный" || data.data.Вид_пропуска === "Материальный" || data.data.Вид_пропуска === "Разовый") {
|
||||
$("#editcar-inputs").css("display", "none");
|
||||
$("#edittmc-inputs").css("display", "none");
|
||||
} else if (data.data.Вид_пропуска === "Автомобильный") {
|
||||
|
@ -12,9 +12,7 @@
|
||||
<title>Бюро пропусков</title>
|
||||
<style>
|
||||
body {
|
||||
/* background-color: #EEEFF5; */
|
||||
background: url(../img/bg.jpeg) no-repeat center center fixed;
|
||||
background-size: cover;
|
||||
background-color: #EEEFF5;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
Loading…
Reference in New Issue
Block a user