Merge branch 'Worker_Raspaev' into Storekeeper

This commit is contained in:
dasha 2023-05-19 15:29:03 +04:00
commit c15757969f
22 changed files with 2806 additions and 260 deletions

View File

@ -152,6 +152,7 @@ namespace HardwareShopContracts.BusinessLogicsContracts
/// <param name="model"></param>
public void SendByMailPurchaseReport(ReportBindingModel model)
{
model.FileName = "temp.pdf";
_saveToPdf.GetPurchaseReportFile(new()
{
FileName = model.FileName,

View File

@ -26,7 +26,7 @@ namespace HardwareShopBusinessLogic.OfficePackage
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
CreateTable(new List<string> { "5cm", "5cm", "5cm", "5cm", "5cm" });
CreateTable(new List<string> { "3cm", "4cm", "3cm", "4cm", "4cm" });
CreateRow(new PdfRowParameters
{
@ -73,7 +73,7 @@ namespace HardwareShopBusinessLogic.OfficePackage
});
}
}
CreateParagraph(new PdfParagraph { Text = $"Итого: {info.ReportPurchases.Sum(x => x.PurchaseSum)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Left });
SavePdf(info);
}

View File

@ -24,8 +24,8 @@
</tbody>
</table>
<div class="col d-flex justify-content-evenly align-items-baseline">
<button type="button" class="btn btn-primary btn-lg m-2" id="savedoc">Сохранить в doc-формате</button>
<button type="button" class="btn btn-primary btn-lg m-2" id="saveexcel">Сохранить в xls-формате</button>
<button type="button" class="btn btn-primary m-2" id="savedoc">Сохранить в doc-формате</button>
<button type="button" class="btn btn-primary m-2" id="saveexcel">Сохранить в xls-формате</button>
</div>
</div>

View File

@ -10,7 +10,7 @@ namespace HardwareShopDatabaseImplement
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseNpgsql("Host=localhost;Port=5433;Database=Computer_Hardware_Store;Username=user;Password=12345");
optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=Computer_Hardware_Store4;Username=postgres;Password=1234");
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
}

View File

@ -122,7 +122,15 @@ namespace HardwareShopRestApi.Controllers
[HttpPost]
public void SendByMailPurchaseReport(ReportBindingModel reportModel)
{
_reportWorkerLogic.SendByMailPurchaseReport(reportModel);
try
{
_reportWorkerLogic.SendByMailPurchaseReport(reportModel);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения сведений по полученным пользователем комплектующим за период");
throw;
}
}
}

View File

@ -1,4 +1,5 @@
using HardwareShopContracts.BindingModels;
using DocumentFormat.OpenXml.Spreadsheet;
using HardwareShopContracts.BindingModels;
using HardwareShopContracts.SearchModels;
using HardwareShopContracts.ViewModels;
using HardwareShopDatabaseImplement.Models;
@ -56,9 +57,39 @@ namespace HardwareShopWorkerApp.Controllers
return View();
}
[HttpGet]
public IActionResult Privacy()
{
return View();
if (APIClient.User == null)
{
return Redirect("~/Home/Enter");
}
return View(APIClient.User);
}
[HttpPost]
public void Privacy(string login, string email, string password)
{
if (APIClient.User == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password))
{
throw new Exception("Введите логин, пароль и ФИО");
}
APIClient.PostRequest("api/user/updatedata", new UserBindingModel
{
Id = APIClient.User.Id,
Login = login,
Email = email,
Password = password
});
APIClient.User.Login = login;
APIClient.User.Email = email;
APIClient.User.Password = password;
Response.Redirect("MainWorker");
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]

View File

@ -15,6 +15,7 @@
<div class=" col-sm-8">
<div class="text-center">
<h2 class="display-4">Сборки</h2>
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#createModal">Добавить</button>
</div>
<div class="text-center" name="id">
<table class="table">
@ -48,15 +49,15 @@
@Html.DisplayFor(modelItem => item.BuildName)
</td>
<td>
<div>
<button onclick="getBuild(@item.Id)" type="button" class="btn btn-primary btn-lg mb-5" data-bs-toggle="modal" data-bs-target="#updateModal">
<i class="fa fa-pencil" aria-hidden="true"></i>
</button>
<button onclick="getBuild(@item.Id)" type="button" class="btn btn-primary btn-lg mb-5" data-bs-toggle="modal" data-bs-target="#deleteModal">
<i class="fa fa-trash" aria-hidden="true"></i>
</button>
<a class="btn btn-primary btn-lg mb-5" asp-controller="Home" asp-action="LinkPurchase" asp-route-buildId="@item.Id"></a>
</div>
<a class="btn btn-success" asp-controller="Home" asp-action="LinkPurchase" asp-route-buildId="@item.Id">
<i class="fa fa-paperclip fa-rotate-90" aria-hidden="true"></i>
</a>
<button onclick="getBuild(@item.Id)" type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#updateModal">
<i class="fa fa-pencil" aria-hidden="true"></i>
</button>
<button onclick="getBuild(@item.Id)" type="button" class="btn btn-danger" data-bs-toggle="modal" data-bs-target="#deleteModal">
<i class="fa fa-trash" aria-hidden="true"></i>
</button>
</td>
</tr>
}
@ -65,13 +66,6 @@
</div>
</div>
<div class="text-center d-flex flex-column mt-5">
<button type="button" class="btn btn-primary btn-lg mb-5" data-bs-toggle="modal" data-bs-target="#createModal">Добавить</button>
<button type="button" class="btn btn-primary btn-lg mb-5" data-bs-toggle="modal" data-bs-target="#exampleModal">Изменить</button>
<button type="button" class="btn btn-primary btn-lg mb-5">Удалить</button>
<button type="button" class="btn btn-primary btn-lg mb-5">Обновить</button>
<button type="submit" class="btn btn-primary btn-lg mb-5">Привязать сборку</button>
</div>
<div class="modal fade" id="createModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">

View File

@ -17,6 +17,7 @@
<div class=" col-sm-8">
<div class="text-center">
<h2 class="display-4">Комментарии</h2>
<button type="button" class="btn btn-primary " data-bs-toggle="modal" data-bs-target="#createModal">Добавить</button>
</div>
<div class="text-center" name="id">
<table class="table">
@ -29,7 +30,7 @@
Текст
</th>
<th>
Название сборки к которой относиться комментарий
Название сборки к которой относится комментарий
</th>
<th>
Действия
@ -50,10 +51,12 @@
@Html.DisplayFor(modelItem => item.BuildName)
</td>
<td>
<div>
<button onclick="getComment(@item.Id)" type="button" class="btn btn-primary btn-lg mb-5" data-bs-toggle="modal" data-bs-target="#updateModal">Изменить</button>
<button onclick="getComment(@item.Id)" type="button" class="btn btn-primary btn-lg mb-5" data-bs-toggle="modal" data-bs-target="#deleteModal">Удалить</button>
</div>
<button onclick="getComment(@item.Id)" type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#updateModal">
<i class="fa fa-pencil" aria-hidden="true"></i>
</button>
<button onclick="getComment(@item.Id)" type="button" class="btn btn-danger" data-bs-toggle="modal" data-bs-target="#deleteModal">
<i class="fa fa-trash" aria-hidden="true"></i>
</button>
</td>
</tr>
}
@ -61,10 +64,6 @@
</table>
</div>
</div>
<div class="text-center d-flex flex-column mt-5">
<button type="button" class="btn btn-primary btn-lg mb-5" data-bs-toggle="modal" data-bs-target="#createModal">Добавить</button>
<button type="button" class="btn btn-primary btn-lg mb-5">Обновить</button>
</div>
<div class="modal fade" id="createModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">

View File

@ -16,7 +16,6 @@
<h1 class="display-6">Товары</h1>
<div class="d-flex justify-content-center">
<button type="button" class="btn btn-primary mx-2 mt-3" data-bs-toggle="modal" data-bs-target="#exampleModal">Добавить</button>
<button type="button" class="btn btn-primary mx-2 mt-3">Удалить</button>
</div>
<table class="table table-hover">
<thead>
@ -147,70 +146,4 @@
}
</script>
}
@*<form class="d-flex justify-content-evenly">
<div class=" col-sm-8">
<div class="text-center">
<h2 class="display-4">Товары</h2>
</div>
<div class="text-center" name="id">
<table class="table">
<thead>
<tr>
<th>
Номер
</th>
<th>
Название товара
</th>
<th>
Цена
</th>
<th>
Количество
</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<div class="text-center d-flex flex-column mt-5">
<button type="button" class="btn btn-primary btn-lg mb-5" data-bs-toggle="modal" data-bs-target="#exampleModal">Добавить</button>
<button type="button" class="btn btn-primary btn-lg mb-5" data-bs-toggle="modal" data-bs-target="#exampleModal">Изменить</button>
<button type="button" class="btn btn-primary btn-lg mb-5">Удалить</button>
<button type="button" class="btn btn-primary btn-lg mb-5">Обновить</button>
<button type="button" class="btn btn-primary btn-lg mb-5">Сохранить</button>
</div>
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Товар</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Закрыть"></button>
</div>
<div class="modal-body">
<div>
<label class="form-label">Товар</label>
<select class="form-select">
<option value="1">Товар 1</option>
<option value="2">Товар 2</option>
</select>
</div>
<div>
<label class="form-label">Количество</label>
<input type="number" class="form-control">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Закрыть</button>
<button type="button" class="btn btn-primary">Сохранить</button>
</div>
</div>
</div>
</div>
</form>
*@
}

View File

@ -13,7 +13,7 @@
<div class="text-center">
@{
<p>
<button type="button" onclick="getBuild()" class="btn btn-primary btn-lg mb-5" data-bs-toggle="modal" data-bs-target="#createModal">Добавить</button>
<button type="button" onclick="getBuild()" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#createModal">Добавить</button>
</p>
<table class="table">
<thead>
@ -224,11 +224,11 @@
</div>
</div>
<div class="text-center d-flex flex-column mt-5">
<button type="button" class="btn btn-primary btn-lg mb-5" data-bs-toggle="modal" data-bs-target="#exampleModal">Добавить</button>
<button type="button" class="btn btn-primary btn-lg mb-5" data-bs-toggle="modal" data-bs-target="#exampleModal">Изменить</button>
<button type="button" class="btn btn-primary btn-lg mb-5">Удалить</button>
<button type="button" class="btn btn-primary btn-lg mb-5">Обновить</button>
<button type="submit" class="btn btn-primary btn-lg mb-5">Сохранить</button>
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModal">Добавить</button>
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModal">Изменить</button>
<button type="button" class="btn btn-primary">Удалить</button>
<button type="button" class="btn btn-primary">Обновить</button>
<button type="submit" class="btn btn-primary">Сохранить</button>
</div>
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">

View File

@ -0,0 +1,29 @@
@using HardwareShopContracts.ViewModels;
@model UserViewModel
@{
ViewData["Title"] = "Privacy Policy";
Layout = "~/Views/Shared/_LayoutWorker.cshtml";
}
<div class="text-center">
<h2 class="display-4">Личные данные</h2>
</div>
<form method="post" class="d-flex flex-column align-items-center">
<div class="col-sm-3">
<label class="form-label">Почта:</label>
<input type="text" class="form-control" name="email" value="@Model.Email">
</div>
<div class="col-sm-3">
<label class="form-label">Пароль:</label>
<input type="text" class="form-control" name="password" value="@Model.Password">
</div>
<div class="col-sm-3">
<label class="form-label">Логин:</label>
<input type="text" class="form-control" name="login" value="@Model.Login">
</div>
<div class="col-sm-2 d-flex justify-content-evenly align-items-baseline">
<button type="submit" class="btn btn-primary mt-3 px-4">Подтвердить</button>
</div>
</form>

View File

@ -19,7 +19,7 @@
<a asp-controller="Home" asp-action="CreatePurchase" class="btn btn-primary mx-2">Добавить</a>
<button type="button" class="btn btn-primary mx-2" id="delete">Удалить покупку</button>
<button type="button" class="btn btn-primary mx-2" id="done">Выдан</button>
<button type="button" class="btn btn-primary mx-2" id="update">Обновить</button>
<button type="button" class="btn btn-primary mx-2" id="update">Изменить</button>
</p>
</div>
<div class="text-center">
@ -56,24 +56,12 @@
<td>
@Html.DisplayFor(modelItem => item.PurchaseStatus)
</td>
@*<td>
<div>
<button onclick="getBuild(@item.Id)" type="button" class="btn btn-primary btn-lg mb-5" data-bs-toggle="modal" data-bs-target="#updateModal">Изменить</button>
<button onclick="getBuild(@item.Id)" type="button" class="btn btn-primary btn-lg mb-5" data-bs-toggle="modal" data-bs-target="#deleteModal">Удалить</button>
</div>
</td>*@
</tr>
}
</tbody>
</table>
</div>
</div>
<div class="text-center d-flex flex-column mt-5">
@*<button type="submit" class="btn btn-primary btn-lg mb-5">Изменить</button>
<button type="button" class="btn btn-primary btn-lg mb-5">Удалить</button>
<button type="button" class="btn btn-primary btn-lg mb-5">Обновить</button>*@
</div>
}
</div>

View File

@ -17,7 +17,6 @@
<h1 class="display-6">Товары</h1>
<div class="d-flex justify-content-center">
<button type="button" class="btn btn-primary mx-2 mt-3" data-bs-toggle="modal" data-bs-target="#exampleModal">Добавить</button>
<button type="button" class="btn btn-primary mx-2 mt-3">Удалить</button>
</div>
<table class="table table-hover">
<thead>
@ -68,6 +67,7 @@
const saveBtn = document.getElementById("createpurchase");
const countElem = document.getElementById("count");
const resultTable = document.getElementById("result");
const totalSum = document.getElementById("sum");
submitGoodBtn.addEventListener("click", () => {
console.log('try to add good')
@ -138,7 +138,10 @@
</div><td/></tr>`
count++;
console.log(elem);
price += elem.good.price * elem.count
})
totalSum.value = Math.round(price * 110) / 100
console.log(totalSum.value);
}
function deleteGood(id) {
@ -173,70 +176,4 @@
getPurchase();
</script>
}
@*<form class="d-flex justify-content-evenly">
<div class=" col-sm-8">
<div class="text-center">
<h2 class="display-4">Товары</h2>
</div>
<div class="text-center" name="id">
<table class="table">
<thead>
<tr>
<th>
Номер
</th>
<th>
Название товара
</th>
<th>
Цена
</th>
<th>
Количество
</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<div class="text-center d-flex flex-column mt-5">
<button type="button" class="btn btn-primary btn-lg mb-5" data-bs-toggle="modal" data-bs-target="#exampleModal">Добавить</button>
<button type="button" class="btn btn-primary btn-lg mb-5" data-bs-toggle="modal" data-bs-target="#exampleModal">Изменить</button>
<button type="button" class="btn btn-primary btn-lg mb-5">Удалить</button>
<button type="button" class="btn btn-primary btn-lg mb-5">Обновить</button>
<button type="button" class="btn btn-primary btn-lg mb-5">Сохранить</button>
</div>
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Товар</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Закрыть"></button>
</div>
<div class="modal-body">
<div>
<label class="form-label">Товар</label>
<select class="form-select">
<option value="1">Товар 1</option>
<option value="2">Товар 2</option>
</select>
</div>
<div>
<label class="form-label">Количество</label>
<input type="number" class="form-control">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Закрыть</button>
<button type="button" class="btn btn-primary">Сохранить</button>
</div>
</div>
</div>
</div>
</form>
*@
}

View File

@ -3,29 +3,15 @@
Layout = "~/Views/Shared/_LayoutWorker.cshtml";
}
<h4 class="fw-bold">Отчет по покупкам</h4>
<div id="error-div-shell" class="error-div-shell">
<div>
<p id="error-p" class="error-p mb-2"></p>
<div class="d-flex flex-column align-items-center">
<div class="col-sm-3">
<label class="form-label">С</label>
<input type="date" class="form-control" name="dateFrom" id="date-from-input">
<label class="form-label">По</label>
<input type="date" class="form-control" name="dateTo" id="date-to-input">
</div>
</div>
<div class="d-flex flex-wrap gap-1 align-items-end mb-2">
<div class="mb-2">
<p class="mb-0">Дата начала:</p>
<input id="date-from-input" class="form-control" type="date" />
</div>
<div class="mb-2">
<p class="mb-0">Дата конца:</p>
<input id="date-to-input" class="form-control" type="date" />
</div>
<button id="generate-button" class="button-primary text-button mb-2">
Показать
</button>
<button id="send-by-mail-button" class="button-primary text-button mb-2">
На почту
</button>
<button type="submit" class="btn btn-primary mt-3 px-4" id="generate-button">Вывод на страницу</button>
<button type="submit" class="btn btn-primary mt-3 px-4" id="send-by-mail-button">Отправить на почту</button>
</div>
<p class="mb-0">
@ -34,21 +20,20 @@
<span>&nbsp;по&nbsp;</span>
<span id="date-to-span" class="fw-bold">...</span>
</p>
<div class="table-shell mb-2 border">
<table class="table mb-0">
<thead class="table-head">
<tr>
<th>Номер покупки</th>
<th>Дата покупки</th>
<th>Сумма покупки</th>
<th>Комментарии</th>
<th>Комплектующие</th>
</tr>
</thead>
<tbody id="tbody">
</tbody>
</table>
</div>
<table class="table">
<thead>
<tr>
<th scope="col">Номер покупки</th>
<th scope="col">Дата покупки</th>
<th scope="col">Сумма покупки</th>
<th scope="col">Комментарии</th>
<th scope="col">Комплектующие</th>
</tr>
</thead>
<tbody id="tbody">
</tbody>
</table>
@section Scripts
{
@ -72,9 +57,6 @@
"DateFrom": dateFrom,
"DateTo": dateTo
};
if (!validate(reportModel)) {
return;
}
$.ajax({
url: "/home/WorkerReport",
type: "POST",
@ -94,9 +76,6 @@
"DateFrom": dateFrom,
"DateTo": dateTo
};
if (!validate(reportModel)) {
return;
}
$.ajax({
url: "/home/SendByMailPurchaseReport",
type: "POST",
@ -106,14 +85,6 @@
});
});
dateFromInput.addEventListener("input", () => {
errorDivShell.style.gridTemplateRows = "0fr";
});
dateToInput.addEventListener("input", () => {
errorDivShell.style.gridTemplateRows = "0fr";
});
// ![Event listeners]
// [HTML gen]
@ -167,25 +138,6 @@
// [Other]
const validate = function (reportModel) {
if (isNaN(reportModel["DateFrom"])) {
errorDivShell.style.gridTemplateRows = "1fr";
errorP.innerHTML = "Выберите начальную дату";
return false;
}
if (isNaN(reportModel["DateTo"])) {
errorDivShell.style.gridTemplateRows = "1fr";
errorP.innerHTML = "Выберите конечную дату";
return false;
}
if (reportModel["DateFrom"] >= reportModel["DateTo"]) {
errorDivShell.style.gridTemplateRows = "1fr";
errorP.innerHTML = "Начальная дата должна быть меньше конечной";
return false;
}
return true;
}
const getDate = function (iso) {
const year = iso.substring(0, 4);
const month = iso.substring(5, 7);

View File

@ -24,8 +24,8 @@
</tbody>
</table>
<div class="col d-flex justify-content-evenly align-items-baseline">
<button type="button" class="btn btn-primary btn-lg m-2" id="savedoc">Сохранить в doc-формате</button>
<button type="button" class="btn btn-primary btn-lg m-2" id="saveexcel">Сохранить в xls-формате</button>
<button type="button" class="btn btn-primary m-2" id="savedoc">Сохранить в doc-формате</button>
<button type="button" class="btn btn-primary m-2" id="saveexcel">Сохранить в xls-формате</button>
</div>
</div>

View File

@ -36,6 +36,9 @@
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="WorkerReport">Отчёт</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
</li>
</ul>
</div>
</div>

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 434 KiB