repair(нема карточек)

This commit is contained in:
Дмитрий Блохин 2024-05-28 21:16:51 +04:00
parent 045ddb9f6b
commit f2445bd448
15 changed files with 174 additions and 114 deletions

View File

@ -11,6 +11,6 @@ namespace Contracts.ViewModels
[DisplayName("Страна производитель")] [DisplayName("Страна производитель")]
public string Country { get; set; } = string.Empty; public string Country { get; set; } = string.Empty;
public int UserId { get; set; } public int UserId { get; set; }
public Dictionary<int, IWorkerModel>? WorkerMachines { get; set; } public Dictionary<int, IWorkerModel> WorkerMachines { get; set; } = new();
} }
} }

View File

@ -15,6 +15,6 @@ namespace Contracts.ViewModels
public int UserId { get; set; } public int UserId { get; set; }
public int? ProductionId { get; set; } public int? ProductionId { get; set; }
public string? ProductionName { get; set; } public string? ProductionName { get; set; }
public Dictionary<int, IWorkerModel>? WorkerWorkshops { get; set; } public Dictionary<int, IWorkerModel> WorkerWorkshops { get; set; } = new();
} }
} }

View File

@ -96,11 +96,12 @@ namespace GuarantorAPP.Controllers
return View(new MachineViewModel()); return View(new MachineViewModel());
} }
[HttpPost] [HttpPost]
public IActionResult CreateMachine(int id, string title, int[] workerIds) public IActionResult CreateMachine(int id, string title, string country, int[] workerIds)
{ {
MachineBindingModel model = new MachineBindingModel(); MachineBindingModel model = new MachineBindingModel();
model.Id = id; model.Id = id;
model.Title = title; model.Title = title;
model.Country = country;
model.DateCreate = DateTime.Now; model.DateCreate = DateTime.Now;
model.UserId = UserGuarantor.user!.Id; model.UserId = UserGuarantor.user!.Id;
var workers = _data.GetWorkers(UserGuarantor.user!.Id); var workers = _data.GetWorkers(UserGuarantor.user!.Id);
@ -207,11 +208,13 @@ namespace GuarantorAPP.Controllers
return View(new WorkshopViewModel()); return View(new WorkshopViewModel());
} }
[HttpPost] [HttpPost]
public IActionResult CreateWorkshop(int id, string title, int[] workerIds) public IActionResult CreateWorkshop(int id, string title, string address, string director, int[] workerIds)
{ {
WorkshopBindingModel model = new WorkshopBindingModel(); WorkshopBindingModel model = new WorkshopBindingModel();
model.Id = id; model.Id = id;
model.Title = title; model.Title = title;
model.Address = address;
model.Director = director;
model.DateCreate = DateTime.Now; model.DateCreate = DateTime.Now;
model.UserId = UserGuarantor.user!.Id; model.UserId = UserGuarantor.user!.Id;
var workers = _data.GetWorkers(UserGuarantor.user!.Id); var workers = _data.GetWorkers(UserGuarantor.user!.Id);
@ -220,17 +223,25 @@ namespace GuarantorAPP.Controllers
var worker = workers!.FirstOrDefault(x => x.Id == workerIds[i])!; var worker = workers!.FirstOrDefault(x => x.Id == workerIds[i])!;
model.WorkshopWorker[workerIds[i]] = (worker); model.WorkshopWorker[workerIds[i]] = (worker);
} }
if (model.WorkshopWorker.Count == 0) bool changed = false;
return RedirectToAction("IndexWorkshop"); if (model.WorkshopWorker.Count > 0)
if (id != 0)
{ {
_data.UpdateWorkshop(model); if (id != 0)
{
changed = _data.UpdateWorkshop(model);
}
else
{
changed = _data.CreateWorkshop(model);
}
} }
if (changed)
return RedirectToAction("IndexWorkshop");
else else
{ {
_data.CreateWorkshop(model); ViewBag.AllWorkers = workers;
return View(model);
} }
return RedirectToAction("IndexWorkshop");
} }
[HttpGet] [HttpGet]
public IActionResult Privacy() public IActionResult Privacy()
@ -285,22 +296,37 @@ namespace GuarantorAPP.Controllers
ViewBag.EndDate = endDate; ViewBag.EndDate = endDate;
return View(values); return View(values);
} }
[HttpGet]
public IActionResult WorkerProductChoose()
{
if (!IsLoggedIn)
return RedirectToAction("IndexNonReg");
var workers = _data.GetWorkers(UserId);
return View(workers);
}
[HttpPost]
public IActionResult WorkerProductChoose(List<int> selectedItems, string reportType)
{
string value = string.Join("/", selectedItems);
HttpContext.Session.SetString("Workers", value);
if (reportType.Equals("default"))
return RedirectToAction("WorkerProductReport");
else if (reportType.Equals("excel"))
return RedirectToAction("");
else
return RedirectToAction("");
}
[HttpGet]
public IActionResult WorkerProductReport() public IActionResult WorkerProductReport()
{ {
List<WorkerProductReportViewModel> workerProductReports = new List<WorkerProductReportViewModel> var value = HttpContext.Session.GetString("Workers");
if(value != null)
{ {
new WorkerProductReportViewModel List<int> rawReports = value!.Split(',').Select(x => int.Parse(x)).ToList();
{ var reports = _data.GetProductReports(rawReports);
WorkerName = "Работник 1", return View(reports);
Products = new List<string> { "Изделие первое", "Изделие второе" } }
}, return View(new List<WorkerProductReportViewModel>());
new WorkerProductReportViewModel
{
WorkerName = "Работник 2",
Products = new List<string> { "Изделие одно", "Изделие второе" }
}
};
return View(workerProductReports);
} }
public IActionResult ReportsMenu() public IActionResult ReportsMenu()
{ {

View File

@ -13,8 +13,9 @@ namespace GuarantorAPP
private readonly IMachineLogic _machineLogic; private readonly IMachineLogic _machineLogic;
private readonly IWorkshopLogic _workshopLogic; private readonly IWorkshopLogic _workshopLogic;
private readonly IProductionLogic _productionLogic; private readonly IProductionLogic _productionLogic;
private readonly IProductLogic _productLogic;
public GuarantorData(ILogger logger, IGuarantorLogic guarantorLogic, IWorkerLogic workerLogic, IMachineLogic machineLogic, IWorkshopLogic workshopLogic, IProductionLogic productionLogic) public GuarantorData(ILogger<GuarantorData> logger, IGuarantorLogic guarantorLogic, IWorkerLogic workerLogic, IMachineLogic machineLogic, IWorkshopLogic workshopLogic, IProductionLogic productionLogic, IProductLogic productLogic)
{ {
_logger = logger; _logger = logger;
_guarantorLogic = guarantorLogic; _guarantorLogic = guarantorLogic;
@ -22,6 +23,7 @@ namespace GuarantorAPP
_machineLogic = machineLogic; _machineLogic = machineLogic;
_workshopLogic = workshopLogic; _workshopLogic = workshopLogic;
_productionLogic = productionLogic; _productionLogic = productionLogic;
_productLogic = productLogic;
} }
public GuarantorViewModel? Login(string login, string password) public GuarantorViewModel? Login(string login, string password)
@ -128,5 +130,20 @@ namespace GuarantorAPP
} }
return machineWorkshopTimeReports; return machineWorkshopTimeReports;
} }
public List<WorkerProductReportViewModel>? GetProductReports(List<int> workers)
{
List<WorkerProductReportViewModel> reports = new();
foreach (int i in workers)
{
WorkerProductReportViewModel report = new();
var worker = _workerLogic.ReadElement(new() { Id = i });
report.WorkerName = worker!.Name;
var products = _productLogic.ReadList(new() { WorkerId = i });
if (products != null)
report.Products = products.Select(x => x.Name).ToList();
reports.Add(report);
}
return reports;
}
} }
} }

View File

@ -16,11 +16,13 @@ builder.Services.AddTransient<IWorkerStorage, WorkerStorage>();
builder.Services.AddTransient<IWorkshopStorage, WorkshopStorage>(); builder.Services.AddTransient<IWorkshopStorage, WorkshopStorage>();
builder.Services.AddTransient<IMachineStorage, MachineStorage>(); builder.Services.AddTransient<IMachineStorage, MachineStorage>();
builder.Services.AddTransient<IProductionStorage, ProductionStorage>(); builder.Services.AddTransient<IProductionStorage, ProductionStorage>();
builder.Services.AddTransient<IProductStorage, ProductStorage>();
builder.Services.AddTransient<IGuarantorLogic, GuarantorLogic>(); builder.Services.AddTransient<IGuarantorLogic, GuarantorLogic>();
builder.Services.AddTransient<IWorkerLogic, WorkerLogic>(); builder.Services.AddTransient<IWorkerLogic, WorkerLogic>();
builder.Services.AddTransient<IWorkshopLogic, WorkshopLogic>(); builder.Services.AddTransient<IWorkshopLogic, WorkshopLogic>();
builder.Services.AddTransient<IMachineLogic, MachineLogic>(); builder.Services.AddTransient<IMachineLogic, MachineLogic>();
builder.Services.AddTransient<IProductionLogic, ProductionLogic>(); builder.Services.AddTransient<IProductionLogic, ProductionLogic>();
builder.Services.AddTransient<IProductLogic, ProductLogic>();
builder.Services.AddTransient<GuarantorData>(); builder.Services.AddTransient<GuarantorData>();
builder.Services.AddSession(options => builder.Services.AddSession(options =>

View File

@ -42,7 +42,7 @@
<input type="hidden" name="workerIds" value="@worker.Key" /> <input type="hidden" name="workerIds" value="@worker.Key" />
@worker.Value.Name @worker.Value.Name
</td> </td>
<td>@worker.Value.Position</td> <td>@worker.Value.Specialization</td>
<td class="worker-salary" data-salary="@worker.Value.Salary">@worker.Value.Salary</td> <td class="worker-salary" data-salary="@worker.Value.Salary">@worker.Value.Salary</td>
<td><button type="button" class="deleteWorker" data-worker-id="@worker.Value.Id">Удалить</button></td> <td><button type="button" class="deleteWorker" data-worker-id="@worker.Value.Id">Удалить</button></td>
</tr> </tr>
@ -54,15 +54,11 @@
<option value="">Выберите работника</option> <option value="">Выберите работника</option>
@foreach (var worker in ViewBag.AllWorkers) @foreach (var worker in ViewBag.AllWorkers)
{ {
<option value="@worker.Id" data-salary="@worker.Salary">@worker.Name</option> <option value="@worker.Id" data-specialization="@worker.Specialization" data-salary="@worker.Salary">@worker.Name</option>
} }
</select> </select>
<button type="button" id="addWorker" class="btn btn-secondary">Добавить работника</button> <button type="button" id="addWorker" class="btn btn-secondary">Добавить работника</button>
</div> </div>
<div class="row">
<div class="col-4">Общая зарплата:</div>
<div class="col-8"><input type="text" id="totalSalary" name="totalSalary" readonly /></div>
</div>
<div class="row"> <div class="row">
<div class="col-8"></div> <div class="col-8"></div>
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div> <div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
@ -73,25 +69,18 @@
<script src="https://cdn.datatables.net/1.11.3/js/jquery.dataTables.js"></script> <script src="https://cdn.datatables.net/1.11.3/js/jquery.dataTables.js"></script>
<script> <script>
$(document).ready(function () { $(document).ready(function () {
function updateTotalSalary() {
var totalSalary = 0;
$('#workersTable tbody tr').each(function () {
var salary = $(this).find('.worker-salary').data('salary');
totalSalary += parseFloat(salary);
});
$('#totalSalary').val(totalSalary.toFixed(2));
}
$(document).on('click', '.deleteWorker', function () { $(document).on('click', '.deleteWorker', function () {
var row = $(this).closest('tr'); var row = $(this).closest('tr');
row.remove(); row.remove();
updateTotalSalary();
}); });
$('#addWorker').click(function () { $('#addWorker').click(function () {
var selectedWorker = $('#workerSelect option:selected'); var selectedWorker = $('#workerSelect option:selected');
if (selectedWorker.val()) { if (selectedWorker.val()) {
var workerId = selectedWorker.val(); var workerId = selectedWorker.val();
var workerName = selectedWorker.text();
var workerSalary = selectedWorker.data('salary');
var workerSpecialization = selectedWorker.data('specialization');
var exists = false; var exists = false;
$('#workersTable tbody tr').each(function () { $('#workersTable tbody tr').each(function () {
if ($(this).data('worker-id') == workerId) { if ($(this).data('worker-id') == workerId) {
@ -103,27 +92,19 @@
alert('Этот работник уже добавлен.'); alert('Этот работник уже добавлен.');
return; return;
} }
var workerName = selectedWorker.text();
var workerSalary = selectedWorker.data('salary');
var workerPosition = selectedWorker.data('position');
var newRow = ` var newRow = `
<tr data-worker-id="${workerId}"> <tr data-worker-id="${workerId}">
<td> <td>
<input type="hidden" name="workerIds" value="${workerId}" /> <input type="hidden" name="workerIds" value="${workerId}" />
${workerName} ${workerName}
</td> </td>
<td>${workerPosition}</td> <td>${workerSpecialization}</td>
<td class="worker-salary" data-salary="${workerSalary}">${workerSalary}</td> <td class="worker-salary" data-salary="${workerSalary}">${workerSalary}</td>
<td><button type="button" class="deleteWorker" data-worker-id="${workerId}">Удалить</button></td> <td><button type="button" class="deleteWorker" data-worker-id="${workerId}">Удалить</button></td>
</tr> </tr>
`; `;
$('#workersTable tbody').append(newRow); $('#workersTable tbody').append(newRow);
$('#workerSelect').val(''); $('#workerSelect').val('');
updateTotalSalary();
} else { } else {
alert('Выберите работника для добавления'); alert('Выберите работника для добавления');
} }

View File

@ -29,13 +29,6 @@
<span id="directorError" class="text-danger"></span> <span id="directorError" class="text-danger"></span>
</div> </div>
</div> </div>
<div class="row">
<div class="col-4">Название продукции:</div>
<div class="col-8">
<input type="text" name="productionName" id="productionName" value="@Model.ProductionName" />
<span id="productionNameError" class="text-danger"></span>
</div>
</div>
<div class="container"> <div class="container">
<div>Работники цеха</div> <div>Работники цеха</div>
<div class="table-responsive-lg"> <div class="table-responsive-lg">
@ -56,11 +49,9 @@
<input type="hidden" name="workerIds" value="@worker.Key" /> <input type="hidden" name="workerIds" value="@worker.Key" />
@worker.Value.Name @worker.Value.Name
</td> </td>
<td>@worker.Value.Position</td> <td>@worker.Value.Specialization</td>
<td>@worker.Value.Salary</td> <td class="worker-salary" data-salary="@worker.Value.Salary">@worker.Value.Salary</td>
<td> <td><button type="button" class="deleteWorker" data-worker-id="@worker.Value.Id">Удалить</button></td>
<button type="button" class="deleteWorker" data-worker-id="@worker.Value.Id">Удалить</button>
</td>
</tr> </tr>
} }
</tbody> </tbody>
@ -70,15 +61,11 @@
<option value="">Выберите работника</option> <option value="">Выберите работника</option>
@foreach (var worker in ViewBag.AllWorkers) @foreach (var worker in ViewBag.AllWorkers)
{ {
<option value="@worker.Id">@worker.Name</option> <option value="@worker.Id" data-specialization="@worker.Specialization" data-salary="@worker.Salary">@worker.Name</option>
} }
</select> </select>
<button type="button" id="addWorker" class="btn btn-secondary">Добавить работника</button> <button type="button" id="addWorker" class="btn btn-secondary">Добавить работника</button>
</div> </div>
<div class="row">
<div class="col-4">Общая зарплата:</div>
<div class="col-8"><input type="text" id="totalSalary" name="totalSalary" readonly /></div>
</div>
<div class="row"> <div class="row">
<div class="col-8"></div> <div class="col-8"></div>
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div> <div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
@ -89,19 +76,9 @@
<script src="https://cdn.datatables.net/1.11.3/js/jquery.dataTables.js"></script> <script src="https://cdn.datatables.net/1.11.3/js/jquery.dataTables.js"></script>
<script> <script>
$(document).ready(function () { $(document).ready(function () {
function updateTotalSalary() {
var totalSalary = 0;
$('#workersTable tbody tr').each(function () {
var salary = $(this).find('td:eq(2)').text();
totalSalary += parseFloat(salary);
});
$('#totalSalary').val(totalSalary.toFixed(2));
}
$(document).on('click', '.deleteWorker', function () { $(document).on('click', '.deleteWorker', function () {
var row = $(this).closest('tr'); var row = $(this).closest('tr');
row.remove(); row.remove();
updateTotalSalary();
}); });
$('#addWorker').click(function () { $('#addWorker').click(function () {
@ -109,10 +86,8 @@
if (selectedWorker.val()) { if (selectedWorker.val()) {
var workerId = selectedWorker.val(); var workerId = selectedWorker.val();
var workerName = selectedWorker.text(); var workerName = selectedWorker.text();
var workerData = selectedWorker.data('worker'); var workerSalary = selectedWorker.data('salary');
var workerPosition = workerData.Position; var workerSpecialization = selectedWorker.data('specialization');
var workerSalary = workerData.Salary;
var exists = false; var exists = false;
$('#workersTable tbody tr').each(function () { $('#workersTable tbody tr').each(function () {
if ($(this).data('worker-id') == workerId) { if ($(this).data('worker-id') == workerId) {
@ -120,26 +95,22 @@
return false; return false;
} }
}); });
if (exists) { if (exists) {
alert('Этот работник уже добавлен.'); alert('Этот работник уже добавлен.');
return; return;
} }
var newRow = ` var newRow = `
<tr data-worker-id="${workerId}"> <tr data-worker-id="${workerId}">
<td> <td>
<input type="hidden" name="workerIds" value="${workerId}" /> <input type="hidden" name="workerIds" value="${workerId}" />
${workerName} ${workerName}
</td> </td>
<td>${workerPosition}</td> <td>${workerSpecialization}</td>
<td>${workerSalary}</td> <td class="worker-salary" data-salary="${workerSalary}">${workerSalary}</td>
<td><button type="button" class="deleteWorker" data-worker-id="${workerId}">Удалить</button></td> <td><button type="button" class="deleteWorker" data-worker-id="${workerId}">Удалить</button></td>
</tr> </tr>
`; `;
$('#workersTable tbody').append(newRow); $('#workersTable tbody').append(newRow);
updateTotalSalary();
$('#workerSelect').val(''); $('#workerSelect').val('');
} else { } else {
alert('Выберите работника для добавления'); alert('Выберите работника для добавления');

View File

@ -5,9 +5,9 @@
<div class="text-center"> <div class="text-center">
<h1 class="display-4">Главное меню</h1> <h1 class="display-4">Главное меню</h1>
<div class="list-group"> <div class="list-group">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="IndexDetail">Станки</a> <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="IndexWorker">Работники</a>
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="IndexProduct">Работники</a> <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="IndexMachine">Станки</a>
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="IndexProduction">Цеха</a> <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="IndexWorkshop">Цеха</a>
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Личные данные</a> <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Logout">Выйти</a> <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Logout">Выйти</a>
</div> </div>

View File

@ -37,7 +37,7 @@
Директор цеха Директор цеха
</th> </th>
<th> <th>
Работник Производство
</th> </th>
<th> <th>
Привязка производства к цеху Привязка производства к цеху
@ -69,6 +69,9 @@
<th> <th>
@Html.DisplayFor(modelItem => item.ProductionName) @Html.DisplayFor(modelItem => item.ProductionName)
</th> </th>
<td>
<a asp-action="WorkshopProductionAdd" asp-route-id="@item.Id" class="btn btn-primary">Привязать производство</a>
</td>
<td> <td>
<a asp-action="CreateWorkshop" asp-route-id="@item.Id" class="btn btn-primary">Изменить</a> <a asp-action="CreateWorkshop" asp-route-id="@item.Id" class="btn btn-primary">Изменить</a>
</td> </td>

View File

@ -35,29 +35,35 @@
<script> <script>
$(document).ready(function () { $(document).ready(function () {
function validateDates() { function validateDates() {
var startDate = new Date($('#startDate').val()); var startDate = $('#startDate').val();
var endDate = new Date($('#endDate').val()); var endDate = $('#endDate').val();
var today = new Date(); var today = new Date().toISOString().split('T')[0];
var isValid = true; var isValid = true;
$('#startDateError').text(''); $('#startDateError').text('');
$('#endDateError').text(''); $('#endDateError').text('');
// Проверка, что даты не превосходят сегодняшнюю дату if (!startDate) {
if (startDate > today) { $('#startDateError').text('Пожалуйста, выберите дату начала.');
$('#startDateError').text('Дата начала не может быть больше сегодняшней даты.');
isValid = false; isValid = false;
} }
if (endDate > today) { if (!endDate) {
$('#endDateError').text('Дата окончания не может быть больше сегодняшней даты.'); $('#endDateError').text('Пожалуйста, выберите дату окончания.');
isValid = false; isValid = false;
} }
// Проверка, что стартовая дата не превосходит конечную дату if (isValid) {
if (startDate > endDate) { if (startDate > today) {
$('#endDateError').text('Дата окончания не может быть раньше даты начала.'); $('#startDateError').text('Дата начала не может быть больше сегодняшней даты.');
isValid = false; isValid = false;
}
if (endDate > today) {
$('#endDateError').text('Дата окончания не может быть больше сегодняшней даты.');
isValid = false;
}
if (startDate > endDate) {
$('#endDateError').text('Дата окончания не может быть раньше даты начала.');
isValid = false;
} }
return isValid; return isValid;
} }

View File

@ -3,7 +3,7 @@
@model List<MachineWorkshopTimeReport> @model List<MachineWorkshopTimeReport>
@{ @{
ViewData["Title"] = "Machines and Workshops on Time Reports"; ViewData["Title"] = "Отчет по станкам и цехам по дате";
} }
<div class="text-center"> <div class="text-center">

View File

@ -5,7 +5,7 @@
<div class="text-center"> <div class="text-center">
<h1 class="display-4">Меню создания отчетов</h1> <h1 class="display-4">Меню создания отчетов</h1>
<div class="list-group"> <div class="list-group">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="WorkerProductReport">Отчет работник-изделие</a> <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="WorkerProductChoose">Отчет работник-изделие</a>
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="MachineWorkshopTimeChoose">Отчет по станкам и цехам по датам</a> <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="MachineWorkshopTimeChoose">Отчет по станкам и цехам по датам</a>
</div> </div>
</div> </div>

View File

@ -0,0 +1,54 @@
@using Contracts.ViewModels;
@model List<WorkerViewModel>
@{
ViewData["Title"] = "Выбор работников для отчета";
}
<h2>Выберите рвботников для отчета</h2>
<form asp-controller="Home" asp-action="WorkerProductChoose" method="post" onsubmit="return validateForm()">
<table class="table">
<thead>
<tr>
<th>Select</th>
<th>Name</th>
</tr>
</thead>
<tbody>
@for (int i = 0; i < Model.Count; i++)
{
<tr>
<td>
<input type="checkbox" name="selectedItems" value="@Model[i].Id" />
</td>
<td>@Model[i].Name</td>
</tr>
}
</tbody>
</table>
<input type="hidden" id="reportType" name="reportType" value="default" />
<button type="submit" class="btn btn-primary" onclick="setReportType('default')">Сгенерировать отчет</button>
<button type="submit" class="btn btn-secondary" onclick="setReportType('excel')">Сгенерировать отчет в Excel</button>
<button type="submit" class="btn btn-secondary" onclick="setReportType('word')">Сгенерировать отчет в Word</button>
<div id="validationMessage" style="display:none;color:red;">Пожалуйста, выберите хотя бы одного работника.</div>
</form>
@section Scripts {
<script>
function validateForm() {
var checkboxes = document.querySelectorAll('input[name="selectedItems"]:checked');
if (checkboxes.length === 0) {
document.getElementById('validationMessage').style.display = 'block';
return false;
} else {
document.getElementById('validationMessage').style.display = 'none';
return true;
}
}
function setReportType(type) {
document.getElementById('reportType').value = type;
}
</script>
}

View File

@ -3,7 +3,7 @@
@model List<WorkerProductReportViewModel> @model List<WorkerProductReportViewModel>
@{ @{
ViewData["Title"] = "Workers - Product Reports"; ViewData["Title"] = "Отчет работник - изделие";
} }
<div class="text-center"> <div class="text-center">
<h1 class="display-4">Список работников с отображением изделий</h1> <h1 class="display-4">Список работников с отображением изделий</h1>

View File

@ -7,11 +7,11 @@
} }
<div class="text-center"> <div class="text-center">
<h1 class="display-4">Цех - @ViewBag.Workshop.Name</h1> <h1 class="display-4">Цех - @ViewBag.Workshop.Title</h1>
</div> </div>
<div class="container"> <div class="container">
<h1>Список цехов</h1> <h1>Список производств</h1>
<div class="row"> <div class="row">
@foreach (var production in Model) @foreach (var production in Model)
{ {