CourseWorkElectronicsShop/ElectronicsShop/ElectronicsShopEmployeeApp/Views/Home/Report.cshtml

136 lines
4.1 KiB
Plaintext
Raw Normal View History

2024-08-09 15:14:33 +04:00
@using ElectronicsShopContracts.ViewModels
@model List<ProductViewModel>
@{
2024-07-28 13:06:28 +04:00
ViewData["Title"] = "Report";
}
2024-08-09 15:14:33 +04:00
<script src="~/lib/jquery/dist/jquery.min.js"></script>
2024-07-28 13:06:28 +04:00
<div class="text-center">
2024-08-09 15:14:33 +04:00
<h1 class="display-4">Отчеты</h1>
2024-07-28 13:06:28 +04:00
</div>
2024-08-09 15:14:33 +04:00
<div class="text-start">
<h2 class="display-4">Отчёт за период</h2>
</div>
2024-07-28 13:06:28 +04:00
<form method="post">
<div class="align-content-center row mb-3">
<div class="col-sm-auto">
<label>С:</label>
</div>
<div class="col-3">
<input name="DateFrom" id="datefrom" type="date" />
</div>
<div class="col-sm-auto">
<label>По:</label>
</div>
<div class="col-3">
<input name="DateTo" id="dateto" type="date" />
</div>
<div class="row">
<div class="col-8"></div>
2024-08-09 15:14:33 +04:00
<div class="col-4"><input type="submit" value="Cформировать отчет" class="btn btn-sm btn-outline-danger m-2 p-2" /></div>
2024-07-28 13:06:28 +04:00
</div>
</div>
2024-08-09 15:14:33 +04:00
</form>
<div class="text-start">
<h2 class="display-5">Выбрать товары в отечет</h2>
</div>
<div class="text-center">
@{
if (Model == null) {
<h3 class="display-4">Авторизируйтесь</h3>
return;
}
<div class="text-end">
<button class="btn btn-sm btn-outline-danger m-2 p-2" id="btnFix">Cформировать отчет</button>
</div>
<table class="table">
<thead>
<tr>
<th>
Номер товара
</th>
<th>
Наименование товара
</th>
<th>
Стоимость
</th>
<th>
Номер статьи затрат
</th>
<th>
Наименование статьи затрат
</th>
<th>
<input type="checkbox" class="form-check-input" id="Select_all" name="Select_all" /> Выбрать все
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model) {
<tr>
<th>
@Html.DisplayFor(modelItem => item.ID)
</th>
<th>
@Html.DisplayFor(modelItem => item.ProductName)
</th>
<th>
@Html.DisplayFor(modelItem => item.Price)
</th>
<th>
@Html.DisplayFor(modelItem => item.CostItemID)
</th>
<th>
@Html.DisplayFor(modelItem => item.CostItemName)
</th>
<th>
<input type="checkbox" class="form-check-input" id="Select_rec" name="Select_rec" value="@item.ID" />
</th>
</tr>
}
</tbody>
</table>
}
</div>
<script>
$('#Select_all').on('click', function () {
let checkboxes = document.getElementsByTagName('input');
let val = null;
for (var i = 0; i < checkboxes.length; i++) {
if (checkboxes[i].type === 'checkbox') {
if (val == null) {
val = checkboxes[i].checked;
}
else {
checkboxes[i].checked = val;
}
}
}
});
$('#btnFix').on('click', function () {
let val = [];
$("input[name='Select_rec']:checked").each(function () {
val.push($(this).val());
});
var str = 'ids=';
for (let i = 0; i < val.length - 1; i++) {
str += val[i] + '&='
}
str += val[val.length - 1];
window.location.href = "ReportSearchFix/" + str;
});
</script>