Быстрый коммит
This commit is contained in:
parent
a445a2307d
commit
3219dc28fe
@ -12,31 +12,40 @@ namespace GarmentFactoryBusinessLogic.OfficePackage
|
||||
{
|
||||
public void CreateDoc(PdfInfoImplementer info)
|
||||
{
|
||||
//CreatePdf(info);
|
||||
//CreateParagraph(new PdfParagraph { Text = info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center });
|
||||
//CreateParagraph(new PdfParagraph { Text = $"с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center });
|
||||
CreatePdf(info);
|
||||
CreateParagraph(new PdfParagraph { Text = info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center });
|
||||
CreateParagraph(new PdfParagraph { Text = $"с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center });
|
||||
//!!!МБ ТУТ НЕЛЬЗЯ ДРОБНЫЕ ЧИСЛА ИЛИ МОЖНО С ТОЧКОЙ
|
||||
CreateTable(new List<string> { "1,5cm", "3cm", "3cm", "2,5cm", "1,5cm", "4cm", "3cm", "3cm", "3cm", "3cm" });
|
||||
|
||||
//CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm", "3cm" });
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { "ID заказа", "Дата заказа", "Стоимость заказа", "Статус заказа", "ID заявки", "ФИО клиента", "Дата заявки", "Название сборки", "Каетегория сборки", "Цена сборки" },
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
|
||||
//CreateRow(new PdfRowParameters
|
||||
//{
|
||||
// Texts = new List<string> { "Номер", "Дата заказа", "Текстиль", "Статус", "Сумма" },
|
||||
// Style = "NormalTitle",
|
||||
// ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
//});
|
||||
foreach (var order in info.Orders)
|
||||
{
|
||||
foreach (var request in order.RequestsAssemblies)
|
||||
{
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { order.OrderId.ToString(), order.DateCreateOrder.ToShortDateString(), order.OrderSum.ToString(), order.OrderStatus.ToString(),
|
||||
request.RequestId.ToString(), request.ClientFIO, request.DateRequest.ToShortDateString(),
|
||||
string.IsNullOrEmpty(request.AssemblyName) ? "Сборка не привязана" : request.AssemblyName,
|
||||
string.IsNullOrEmpty(request.AssemblyCategory) ? "Неизвестная категория" : request.AssemblyCategory,
|
||||
request.AssemblyPrice.ToString()
|
||||
},
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||
});
|
||||
}
|
||||
|
||||
//foreach (var order in info.Orders)
|
||||
//{
|
||||
// CreateRow(new PdfRowParameters
|
||||
// {
|
||||
// Texts = new List<string> { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.TextileName, order.Status.ToString(), order.Sum.ToString() },
|
||||
// Style = "Normal",
|
||||
// ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||
// });
|
||||
//}
|
||||
}
|
||||
//CreateParagraph(new PdfParagraph { Text = $"Итого: {info.Orders.Sum(x => x.Sum)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Rigth });
|
||||
|
||||
//SavePdf(info);
|
||||
SavePdf(info);
|
||||
}
|
||||
protected abstract void CreatePdf(PdfInfoImplementer info);
|
||||
protected abstract void CreateParagraph(PdfParagraph paragraph);
|
||||
|
@ -21,9 +21,12 @@ namespace ComputerShopContracts.BusinessLogicContracts
|
||||
/// Получение отчёта для почты
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
List<ReportOrdersViewModel> GetReportOrdersByDates(UserSearchModel currentUser, ReportBindingModel report);
|
||||
List<ReportOrdersViewModel> GetReportOrdersByDates(ReportBindingModel report);
|
||||
void SaveReportOrderAssembliesToWordFile(ReportBindingModel model);
|
||||
|
||||
void SaveReportOrderAssembliesToExcelFile(ReportBindingModel model);
|
||||
|
||||
void SaveReportOrdersByDatesToPdfFile(ReportBindingModel model);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -6,16 +6,19 @@ using System.Diagnostics;
|
||||
using ComputerShopDataModels.Enums;
|
||||
using ComputerShopDataModels.Models;
|
||||
using ComputerShopContracts.SearchModels;
|
||||
using ComputerShopContracts.BusinessLogicContracts;
|
||||
|
||||
namespace ComputerShopImplementerApp.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
private readonly ILogger<HomeController> _logger;
|
||||
private readonly IReportImplementerLogic _logic;
|
||||
|
||||
public HomeController(ILogger<HomeController> logger)
|
||||
public HomeController(ILogger<HomeController> logger, IReportImplementerLogic logic)
|
||||
{
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
@ -539,7 +542,6 @@ namespace ComputerShopImplementerApp.Controllers
|
||||
APIUser.PostRequest("api/order/createreporttowordfile", new ReportBindingModel
|
||||
{
|
||||
Ids = ids,
|
||||
//FileName = "C:\\ReportsCourseWork\\wordfile.docx"
|
||||
FileName = "C:\\!КУРСОВАЯ\\Сборки по выбранным заказам.docx"
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
@ -550,7 +552,6 @@ namespace ComputerShopImplementerApp.Controllers
|
||||
APIUser.PostRequest("api/order/createreporttoexcelfile", new ReportBindingModel
|
||||
{
|
||||
Ids = ids,
|
||||
//FileName = "C:\\ReportsCourseWork\\wordfile.docx"
|
||||
FileName = "C:\\!КУРСОВАЯ\\Сборки по выбранным заказам.xlsx"
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
@ -558,6 +559,47 @@ namespace ComputerShopImplementerApp.Controllers
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult ReportOrdersByDates()
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
//ViewBag.Orders = APIUser.GetRequest<List<OrderViewModel>>($"api/order/getorders?userId={APIUser.User.Id}");
|
||||
//ViewBag.Statuses =
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public string GetOrdersReportByDates(DateTime dateFrom, DateTime dateTo)
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
throw new Exception("Вход только авторизованным");
|
||||
}
|
||||
List<ReportOrdersViewModel> result;
|
||||
try
|
||||
{
|
||||
result = _logic.GetReportOrdersByDates(new ReportBindingModel
|
||||
{
|
||||
UserId = APIUser.User.Id,
|
||||
DateFrom = dateFrom,
|
||||
DateTo = dateTo
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания отчета");
|
||||
throw;
|
||||
}
|
||||
string table = "";
|
||||
return table;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// ОСТАЛЬНОЕ ОСТАЛЬНОЕ ОСТАЛЬНОЕ ОСТАЛЬНОЕ ОСТАЛЬНОЕ ОСТАЛЬНОЕ ОСТАЛЬНОЕ
|
||||
|
||||
[HttpGet]
|
||||
|
@ -0,0 +1,82 @@
|
||||
@using ComputerShopContracts.ViewModels
|
||||
@{
|
||||
ViewData["Title"] = "Report by dates";
|
||||
}
|
||||
|
||||
<form method="post">
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Отчёт за период по заказам</h2>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="mb-3" for="dateFrom">Начало периода</label>
|
||||
<input type="datetime-local" placeholder="Выберите дату начала периода" id="dateFrom" name="dateFrom" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="mb-3" for="dateTo">Окончание периода</label>
|
||||
<input type="datetime-local" placeholder="Выберите дату окончания периода" id="dateTo" name="dateTo"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="mb-3">Текущий статус заказа:</label>
|
||||
@* <input class="mb-3" type="text" id="currentStatus" name="currentStatus" readonly /> *@
|
||||
<span id="currentStatus" style="font-weight: bold;"></span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<button type="button" id="show">Вывести здесь</button>
|
||||
<div class="col-4"><input type="submit" value="Отправить на почту" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
<div class="mt-3" id="report">
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
<script>
|
||||
function check() {
|
||||
var dateFrom = $('#dateFrom').val();
|
||||
var dateTo = $('#dateTo').val();
|
||||
if (dateFrom && dateTo) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetOrdersReportByDates",
|
||||
data: { dateFrom: dateFrom, dateTo: dateTo },
|
||||
success: function (result) {
|
||||
if (result != null) {
|
||||
$('#report').html(result);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
check();
|
||||
$('#show').on('click', (e) => check());
|
||||
|
||||
|
||||
// $('#order').on('change', function () {
|
||||
// check();
|
||||
// });
|
||||
// var orderStatusNames = [
|
||||
// "Неизвестен",
|
||||
// "Принят",
|
||||
// "Выполняется",
|
||||
// "Готов",
|
||||
// "Выдан"
|
||||
// ];
|
||||
// function check() {
|
||||
// var order = $('#order').val();
|
||||
// if (order) {
|
||||
// $.ajax({
|
||||
// method: "GET",
|
||||
// url: "/Home/GetOrder",
|
||||
// data: { orderId: order },
|
||||
// success: function (result) {
|
||||
// console.log(result);
|
||||
// var localDate = result.dateCreate.toLocaleString();
|
||||
// $("#date").val(localDate);
|
||||
// //!!!ТУТ КАК-ТО ВЫВЕСТИ СТАТУС
|
||||
// var orderStatusName = orderStatusNames[result.status + 1];
|
||||
// $("#currentStatus").text(orderStatusName);
|
||||
// $("#sum").val(result.sum);
|
||||
// }
|
||||
// });
|
||||
// };
|
||||
// }
|
||||
</script>
|
@ -38,7 +38,9 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="ReportOrdersAssembliesToFile">Отчёт по заказам в файле</a>
|
||||
</li>
|
||||
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="ReportOrdersByDates">Отчёт за период</a>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
|
@ -89,6 +89,21 @@ namespace ComputerShopRestApi.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public void CreateReportToPDFFile(ReportBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_reportLogic.SaveReportOrdersByDatesToPdfFile(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания отчета");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
//МБ ИЗМЕНИТЬ IEnumerable на List
|
||||
//!!!ПОТОМ УДАЛИТЬ
|
||||
//[HttpGet]
|
||||
|
Loading…
Reference in New Issue
Block a user