new format report is done

This commit is contained in:
Илья Федотов 2024-08-09 15:14:33 +04:00
parent e9041926ab
commit 8cadef8963
20 changed files with 401 additions and 152 deletions

View File

@ -45,17 +45,39 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
foreach (var paymeant in paymeants) {
var order = _orderStorage.GetElement(new OrderSearchModel { ID = paymeant.OrderID }) ?? throw new Exception("Ошибка получения данных");
foreach (var product in order.ProductList) {
paymeantProductList.Add(new(paymeant.ID, product.Key, product.Value.Item2));
paymeantProductList.Add(new(paymeant.ID, product.Key, product.Value.Item2, paymeant.ClientID));
}
}
paymeantProductList.OrderBy(x => x.ProductID);
return CreateProducntInPaymenatList(paymeantProductList);
}
public List<ReportProductInPaymeantsViewModel> GetProductsFix(List<ProductViewModel> products) {
var paymeants = _paymeantStorage.GetFullList();
List<PaymeantProduct> paymeantProducts = new();
foreach (var paymeant in paymeants) {
var order = _orderStorage.GetElement(new OrderSearchModel { ID = paymeant.ID }) ?? throw new Exception("Ошибка получения данных");
foreach (var product in order.ProductList) {
foreach (var fixProduct in products) {
if (product.Value.Item1.ID == fixProduct.ID) {
paymeantProducts.Add(new(paymeant.ID, product.Key, product.Value.Item2, paymeant.ClientID));
}
}
}
}
return CreateProducntInPaymenatList(paymeantProducts);
}
public List<ReportProductInPaymeantsViewModel> CreateProducntInPaymenatList(List<PaymeantProduct> paymeantProducts) {
paymeantProducts.OrderBy(x => x.ProductID);
List<ReportProductInPaymeantsViewModel> ansProductsList = new();
List<string> productNames = new();
foreach (var pp in paymeantProductList) {
var product = _productStorage.GetElement(new ProductSearchModel { ID = pp.ProductID})
foreach (var pp in paymeantProducts) {
var product = _productStorage.GetElement(new ProductSearchModel { ID = pp.ProductID })
?? throw new Exception("Ошибка получения данных");
if (productNames.Contains(product.ProductName) == false) {
productNames.Add(product.ProductName);
@ -72,24 +94,22 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
// Ищем запись и вносим изменения
int index = ansProductsList.IndexOf(ansProductsList.First(x => x.ProductName == product.ProductName));
var paymeant = _paymeantStorage.GetElement(new PaymeantSearchModel { ID = pp.PaymeantID })
var paymeant = _paymeantStorage.GetElement(new PaymeantSearchModel { ID = pp.PaymeantID })
?? throw new Exception("Ошибка получения данных");
ansProductsList[index].Values.Add(new(pp.PaymeantID, pp.Count, paymeant.PayOption.ToString(), product.Price * pp.Count));
ansProductsList[index].Values.Add(new(pp.PaymeantID, pp.Count, paymeant.PayOption.ToString(), product.Price * pp.Count, pp.ClientID));
ansProductsList[index].Total++;
}
return ansProductsList;
}
return ansProductsList;
}
public byte[]? SaveProductsToExcelFile(ReportProductBindingModel model)
public byte[]? SaveProductsToExcelFile(List<ProductViewModel> products)
{
var document = _saveToExcel.CreateReport(new ExcelInfoEmployee
{
Title = "Список оплат электротоваров",
ListProduct = GetProducts(model),
DateTo = model.DateTo,
DateFrom = model.DateFrom
ListProduct = GetProductsFix(products)
});
return document;
}
@ -106,13 +126,11 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
return document;
}
public byte[]? SaveProductsToWordFile(ReportProductBindingModel model)
public byte[]? SaveProductsToWordFile(List<ProductViewModel> products)
{
var document = _saveToWord.CreateDoc(new WordInfoEmployee {
Title = "Список оплат электротоваров",
ListProduct = GetProducts(model),
DateFrom = model.DateFrom,
DateTo = model.DateTo,
ListProduct = GetProductsFix(products)
});
return document;
}

View File

@ -23,19 +23,7 @@ namespace ElectronicsShopBusinessLogic.OfficePackage
CellToName = "C1"
});
InsertCellInWorksheet(new ExcelCellParameters {
ColumnName = "A",
RowIndex = 2,
Text = $"С {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}",
StyleInfo = ExcelStyleInfoType.Title
});
MergeCells(new ExcelMergeParameters {
CellFromName = "A2",
CellToName = "K2"
});
uint rowIndex = 3;
uint rowIndex = 2;
foreach (var product in info.ListProduct) {
InsertCellInWorksheet(new ExcelCellParameters {
ColumnName = "A",
@ -135,7 +123,47 @@ namespace ElectronicsShopBusinessLogic.OfficePackage
CellFromName = $"J{rowIndex}",
CellToName = $"K{rowIndex}"
});
rowIndex++;
InsertCellInWorksheet(new ExcelCellParameters {
ColumnName = "L",
RowIndex = rowIndex,
Text = "Сумма:",
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
InsertCellInWorksheet(new ExcelCellParameters {
ColumnName = "M",
RowIndex = rowIndex,
Text = paymeant.ProductSum.ToString(),
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
InsertCellInWorksheet(new ExcelCellParameters {
ColumnName = "N",
RowIndex = rowIndex,
Text = "ID Клиента:",
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
InsertCellInWorksheet(new ExcelCellParameters {
ColumnName = "O",
RowIndex = rowIndex,
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
MergeCells(new ExcelMergeParameters {
CellFromName = $"N{rowIndex}",
CellToName = $"O{rowIndex}"
});
InsertCellInWorksheet(new ExcelCellParameters {
ColumnName = "P",
RowIndex = rowIndex,
Text = paymeant.ClientID.ToString(),
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
rowIndex++;
}
InsertCellInWorksheet(new ExcelCellParameters {
ColumnName = "A",

View File

@ -29,10 +29,10 @@ namespace ElectronicsShopBusinessLogic.OfficePackage {
Style = "Normal",
alignmentType = PdfParagraphAlignmentType.Left,
});
CreateTable(new List<string> { "2cm", "4cm", "4cm", "4cm" });
CreateTable(new List<string> { "2cm", "4cm", "4cm", "4cm", "2cm" });
CreateRow(new PdfRowParameters {
Text = new List<string> { "Оплата №", "Статус", "Количество товара", "Сумма" },
Text = new List<string> { "Оплата №", "Статус", "Количество товара", "Сумма", "ID Клиента" },
Style = "NormalTittle",
alignmentType = PdfParagraphAlignmentType.Center,
});
@ -43,7 +43,8 @@ namespace ElectronicsShopBusinessLogic.OfficePackage {
paymeant.PaymeantID.ToString(),
paymeant.PaymeantStatus.ToString(),
paymeant.ProducCount.ToString(),
paymeant.ProductSum.ToString()
paymeant.ProductSum.ToString(),
paymeant.ClientID.ToString(),
},
Style = "Normal",
alignmentType= PdfParagraphAlignmentType.Left,

View File

@ -24,15 +24,6 @@ namespace ElectronicsShopBusinessLogic.OfficePackage
}
});
CreateParagraph(new WordParagraph {
Texts = new List<(string, WordTextProperties)> { ($"С {info.DateFrom} по {info.DateTo}", new WordTextProperties { Bold = true, Size = "24", }) },
TextProperties = new WordTextProperties {
Size = "24",
JustificationType = WordJustificationType.Both
}
});
foreach (var data in info.ListProduct) {
CreateParagraph(new WordParagraph {
Texts = new List<(string, WordTextProperties)> { (data.ProductName, new WordTextProperties { Bold = true, Size = "24", }) },
@ -43,7 +34,8 @@ namespace ElectronicsShopBusinessLogic.OfficePackage
});
foreach (var paymeant in data.Values) {
CreateParagraph(new WordParagraph {
Texts = new List<(string, WordTextProperties)> { ($"Оплата №:{paymeant.PaymeantID} статус:{paymeant.PaymeantStatus}",
Texts = new List<(string, WordTextProperties)> { ($"Оплата №:{paymeant.PaymeantID}/В количестве:{paymeant.ProducCount}/" +
$"Cтатус:{paymeant.PaymeantStatus}/Сумма:{paymeant.ProductSum}/ID Клиента:{paymeant.ClientID}",
new WordTextProperties { Bold = false, Size = "24", }) },
TextProperties = new WordTextProperties {
Size = "24",

View File

@ -6,10 +6,6 @@ namespace ElectronicsShopBusinessLogic.OfficePackage.HelperModels
{
public string Title { get; set; } = string.Empty;
public DateTime DateFrom { get; set; }
public DateTime DateTo { get; set; }
public List<ReportPaymeantProductsViewModel> PaymeantProducts { get; set; } = new();
}
}

View File

@ -6,9 +6,6 @@ namespace ElectronicsShopBusinessLogic.OfficePackage.HelperModels
{
public string Title { get; set; } = string.Empty;
public DateTime DateFrom { get; set; }
public DateTime DateTo { get; set; }
public List<ReportProductInPaymeantsViewModel> ListProduct { get; set; } = new();
}
}

View File

@ -8,13 +8,16 @@ namespace ElectronicsShopBusinessLogic.OfficePackage.HelperModels {
public class PaymeantProduct {
public int PaymeantID { get; set; }
public int ProductID { get; set; }
public int ClientID { get; set; }
// количество товара в оплате
public int Count { get; set; }
public PaymeantProduct(int paymeantID, int productID, int count) {
public PaymeantProduct(int paymeantID, int productID, int count, int clientID) {
PaymeantID = paymeantID;
ProductID = productID;
Count = count;
ClientID = clientID;
Count = count;
}
}
}

View File

@ -7,10 +7,6 @@ namespace ElectronicsShopBusinessLogic.OfficePackage.HelperModels
{
public string Title { get; set; } = string.Empty;
public DateTime DateFrom { get; set; }
public DateTime DateTo { get; set; }
public List<ReportProductsViewModel>? Products { get; set; } = new();
}
}

View File

@ -7,9 +7,6 @@ namespace ElectronicsShopBusinessLogic.OfficePackage.HelperModels
{
public string Title { get; set; } = string.Empty;
public DateTime DateFrom { get; set; }
public DateTime DateTo { get; set; }
public List<ReportProductInPaymeantsViewModel> ListProduct { get; set; } = new();
}
}

View File

@ -12,8 +12,11 @@ namespace ElectronicsShopContracts.BusinessLogicContracts
public interface IReportEmployeeLogic
{
List<ReportProductInPaymeantsViewModel> GetProducts(ReportProductBindingModel model);
byte[]? SaveProductsToWordFile(ReportProductBindingModel model);
byte[]? SaveProductsToExcelFile(ReportProductBindingModel model);
List<ReportProductInPaymeantsViewModel> GetProductsFix(List<ProductViewModel> products);
byte[]? SaveProductsToWordFile(List<ProductViewModel> products);
byte[]? SaveProductsToExcelFile(List<ProductViewModel> products);
PdfDocument SaveProductsToPdfFile(ReportProductBindingModel model);
}
}

View File

@ -8,7 +8,7 @@ namespace ElectronicsShopContracts.ViewModels {
public class ReportProductInPaymeantsViewModel {
public string ProductName { get; set; } = string.Empty;
public List<(int PaymeantID, int ProducCount, string PaymeantStatus, double ProductSum)> Values = new();
public List<(int PaymeantID, int ProducCount, string PaymeantStatus, double ProductSum, int ClientID)> Values = new();
// Итоговое количество оплат
public int Total { get; set; }

View File

@ -3,6 +3,7 @@ using ElectronicsShopContracts.BindingModels;
using ElectronicsShopContracts.SearchModels;
using ElectronicsShopContracts.ViewModels;
using ElectronicsShopEmployeeApp.Models;
using Microsoft.AspNetCore.Http.Extensions;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using System.Diagnostics;
@ -322,7 +323,7 @@ namespace ElectronicsShopEmployeeApp.Controllers {
return Redirect("/Home/Index");
}
return View();
return View(APIEmployee.GetRequset<List<ProductViewModel>>($"api/main/getproducts"));
}
[HttpPost]
@ -343,8 +344,31 @@ namespace ElectronicsShopEmployeeApp.Controllers {
}
[HttpGet]
public IActionResult CreateWordReport(string DateFrom, string DateTo) {
var fileMemStream = APIEmployee.GetRequset<byte[]>($"api/Employee/CreateDocxReport?from={DateFrom}&to={DateTo}");
public IActionResult ReportSearchFix() {
string strUrl = Request.GetDisplayUrl();
strUrl = strUrl.Replace("https://localhost:7221/Home/ReportSearchFix/", "");
string ids = "";
List<ProductViewModel> productsFix = new();
foreach (char i in strUrl) {
if (int.TryParse(i.ToString(), out int id)) {
var product = APIEmployee.GetRequset<ProductViewModel>($"api/main/getproduct?_productid={id}") ?? throw new Exception("Òîâàð íå íàéäåí");
productsFix.Add(product);
ids += "/" + id;
}
}
if (string.IsNullOrEmpty(ids)) {
throw new Exception("Íåò âûáðàííûõ òîâàðîâ");
}
(List<ProductViewModel>, string) tuple = (productsFix, ids);
return View(tuple);
}
[HttpGet]
public IActionResult CreateWordReport(string ids) {
var fileMemStream = APIEmployee.GetRequset<byte[]>($"api/Employee/CreateDocxReport?_ids={ids}");
if (fileMemStream == null) {
throw new Exception("Îøèáêà ñîçäàíèÿ îò÷åòà");
@ -354,8 +378,8 @@ namespace ElectronicsShopEmployeeApp.Controllers {
}
[HttpGet]
public IActionResult CreateExcelReport(string DateFrom, string DateTo) {
var fileMemStream = APIEmployee.GetRequset<byte[]>($"api/Employee/CreateXlsxReport?from={DateFrom}&to={DateTo}");
public IActionResult CreateExcelReport(string ids) {
var fileMemStream = APIEmployee.GetRequset<byte[]>($"api/Employee/CreateXlsxReport?_ids={ids}");
if (fileMemStream == null) {
throw new Exception("Îøèáêà ñîçäàíèÿ îò÷åòà");

View File

@ -41,20 +41,20 @@
@foreach (var item in Model) {
<tr>
<th>
@Html.DisplayFor(modelItem => item.ID)
@Html.DisplayFor(modelItem => item.ID)
</th>
<th>
@Html.DisplayFor(modelItem => item.ProductName)
@Html.DisplayFor(modelItem => item.ProductName)
</th>
<th>
@Html.DisplayFor(modelItem => item.CostItemName)
@Html.DisplayFor(modelItem => item.CostItemName)
</th>
<th>
@Html.DisplayFor(modelItem => item.Price)
@Html.DisplayFor(modelItem => item.Price)
</th>
<td>
<a class="btn btn-primary btn-sm" asp-action="EditProduct" asp-route-ID="@item.ID">Изменить</a>
<a class="btn btn-primary btn-sm" asp-action="DeleteProduct" style="background-color:red;" asp-route-ID="@item.ID">Удалить</a>
<a class="btn btn-primary btn-sm" asp-action="EditProduct" asp-route-ID="@item.ID">Изменить</a>
<a class="btn btn-primary btn-sm" asp-action="DeleteProduct" style="background-color:red;" asp-route-ID="@item.ID">Удалить</a>
</td>
</tr>
}

View File

@ -1,9 +1,19 @@
@{
@using ElectronicsShopContracts.ViewModels
@model List<ProductViewModel>
@{
ViewData["Title"] = "Report";
}
<script src="~/lib/jquery/dist/jquery.min.js"></script>
<div class="text-center">
<h2 class="display-4">Отчёты</h2>
<h1 class="display-4">Отчеты</h1>
</div>
<div class="text-start">
<h2 class="display-4">Отчёт за период</h2>
</div>
<form method="post">
<div class="align-content-center row mb-3">
<div class="col-sm-auto">
@ -20,7 +30,107 @@
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Cформировать отчет" class="btn btn-primary" /></div>
<div class="col-4"><input type="submit" value="Cформировать отчет" class="btn btn-sm btn-outline-danger m-2 p-2" /></div>
</div>
</div>
</form>
</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>

View File

@ -9,7 +9,7 @@
<div class="text-center">
<h1 class="row align-items-center mb-3">
<div class="text-center">
<label>Отчет по оплатам:</label>
<label>Предпросмотр отчета:</label>
</div>
<div class="col-sm-auto">
<label>С:</label>
@ -24,11 +24,7 @@
<input name="DateTo" id="dateto" type="text" value="@Model.Item2.Date.ToString("d")" readonly />
</div>
<div class="row">
<div class="col-8">
<a class="btn btn-primary btn-sm" asp-action="CreateWordReport" asp-route-DateFrom="@Model.Item1"
asp-route-DateTo="@Model.Item2" style="background-color:#335a95;">Экспорт отчета в .docx</a>
<a class="btn btn-primary btn-sm" asp-action="CreateExcelReport" asp-route-DateFrom="@Model.Item1"
asp-route-DateTo="@Model.Item2" style="background-color:#04713A;">Экспорт отчета в .xlsx</a>
<div class="text-end">
<a class="btn btn-primary btn-sm" asp-action="CreatePdfReport" asp-route-DateFrom="@Model.Item1"
asp-route-DateTo="@Model.Item2" style="background-color:#ad0d09;">отправить на Email отчет в .pdf</a>
</div>
@ -57,6 +53,9 @@
<th>
Дата оплаты
</th>
<th>
ID Клиента
</th>
</tr>
</thead>
<tbody>
@ -77,6 +76,9 @@
<th>
@Html.DisplayFor(modelItem => item.DatePaymeant)
</th>
<th>
@Html.DisplayFor(modelItem => item.ClientID)
</th>
</tr>
}
</tbody>

View File

@ -0,0 +1,69 @@
@using ElectronicsShopContracts.ViewModels
@model (List<ProductViewModel>, string)
@{
ViewData["Title"] = "ReportSearchFix";
}
<div class="text-center">
<h1 class="row align-items-center mb-3">
<div class="text-center">
<label>Предпросмотр отчета:</label>
</div>
<div class="text-end">
<a class="btn btn-primary btn-sm" asp-action="CreateWordReport" asp-route-ids="@Model.Item2" style="background-color:#335a95;">Экспорт отчета в .docx</a>
<a class="btn btn-primary btn-sm" asp-action="CreateExcelReport" asp-route-ids="@Model.Item2" style="background-color:#04713A;">Экспорт отчета в .xlsx</a>
</div>
</h1>
</div>
<div class="text-center">
@{
if (Model.Item1 == null) {
<h3 class="display-4">Авторизируйтесь</h3>
return;
}
<table class="table">
<thead>
<tr>
<th>
Номер товара
</th>
<th>
Наименование товара
</th>
<th>
Стоимость
</th>
<th>
Номер статьи затрат
</th>
<th>
Наименование статьи затрат
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.Item1) {
<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>
</tr>
}
</tbody>
</table>
}
</div>

View File

@ -10,9 +10,9 @@
</head>
<body>
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light border-bottom box-shadow mb-3" style="background-color:#1e2126">
<div class="container-fluid">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">Магазин электроники (Сотрудник)</a>
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index" style="color:whitesmoke" >Магазин электроники (Сотрудник)</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
@ -20,22 +20,22 @@
<div class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse">
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Товары</a>
<a class="nav-link" asp-area="" asp-controller="Home" asp-action="Index" style="color:whitesmoke">Товары</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
<a class="nav-link" asp-area="" asp-controller="Home" asp-action="Privacy" style="color:whitesmoke">Личные данные</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Enter">Вход</a>
<a class="nav-link" asp-area="" asp-controller="Home" asp-action="Enter" style="color:whitesmoke">Вход</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Register">Регистрация</a>
<a class="nav-link" asp-area="" asp-controller="Home" asp-action="Register" style="color:whitesmoke">Регистрация</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="CostItem">Статьи затрат</a>
<a class="nav-link" asp-area="" asp-controller="Home" asp-action="CostItem" style="color:whitesmoke" >Статьи затрат</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Report">Отчёты</a>
<a class="nav-link" asp-area="" asp-controller="Home" asp-action="Report" style="color:whitesmoke">Отчёты</a>
</li>
</ul>
</div>

View File

@ -155,12 +155,19 @@ namespace ElectronicsShopRestAPI.Controllers {
}
[HttpGet]
public byte[]? CreateDocxReport(string from, string to) {
public byte[]? CreateDocxReport(string _ids) {
try {
var document = _reportEmployeeLogic.SaveProductsToWordFile(new ReportProductBindingModel {
DateFrom = DateTime.Parse(from),
DateTo = DateTime.Parse(to)
});
List<ProductViewModel> _products = new();
foreach (char i in _ids) {
if (int.TryParse(i.ToString(), out int id)) {
var product = _productLogic.ReadElement(new ProductSearchModel { ID = id }) ?? throw new Exception("Ошибка получения данных");
_products.Add(product);
}
}
var document = _reportEmployeeLogic.SaveProductsToWordFile(_products);
return document;
}
catch (Exception ex) {
@ -170,12 +177,19 @@ namespace ElectronicsShopRestAPI.Controllers {
}
[HttpGet]
public byte[]? CreateXlsxReport(string from, string to) {
public byte[]? CreateXlsxReport(string _ids) {
try {
var document = _reportEmployeeLogic.SaveProductsToExcelFile(new ReportProductBindingModel {
DateFrom = DateTime.Parse(from),
DateTo = DateTime.Parse(to)
});
List<ProductViewModel> _products = new();
foreach (char i in _ids) {
if (int.TryParse(i.ToString(), out int id)) {
var product = _productLogic.ReadElement(new ProductSearchModel { ID = id }) ?? throw new Exception("Ошибка получения данных");
_products.Add(product);
}
}
var document = _reportEmployeeLogic.SaveProductsToExcelFile(_products);
return document;
}
catch (Exception ex){

View File

@ -44,58 +44,58 @@
<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>
<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.OrderID)
</th>
<th>
@Html.DisplayFor(modelItem => item.SumPayment)
</th>
<th>
@Html.DisplayFor(modelItem => item.PayOption)
</th>
<th>
@Html.DisplayFor(modelItem => item.DatePaymeant)
</th>
<th>
<input type="checkbox" class="form-check-input" id="Select_rec" name="Select_rec" value="@item.ID" />
</th>
</tr>
<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.OrderID)
</th>
<th>
@Html.DisplayFor(modelItem => item.SumPayment)
</th>
<th>
@Html.DisplayFor(modelItem => item.PayOption)
</th>
<th>
@Html.DisplayFor(modelItem => item.DatePaymeant)
</th>
<th>
<input type="checkbox" class="form-check-input" id="Select_rec" name="Select_rec" value="@item.ID" />
</th>
</tr>
}
</tbody>
</table>
</tbody>
</table>
}
</div>
@ -118,7 +118,6 @@
});
$('#btnFix').on('click', function () {
debugger
let val = [];
$("input[name='Select_rec']:checked").each(function () {
val.push($(this).val());