54 lines
2.0 KiB
Plaintext
54 lines
2.0 KiB
Plaintext
|
@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>
|
||
|
}
|