diff --git a/Factory/FactoryBuisinessLogic/BusinessLogics/StorekeeperReportLogic.cs b/Factory/FactoryBuisinessLogic/BusinessLogics/StorekeeperReportLogic.cs index ec74ddb..3cf175a 100644 --- a/Factory/FactoryBuisinessLogic/BusinessLogics/StorekeeperReportLogic.cs +++ b/Factory/FactoryBuisinessLogic/BusinessLogics/StorekeeperReportLogic.cs @@ -44,7 +44,7 @@ namespace FactoryBusinessLogic.BusinessLogics _saveToPdf.CreateStorekeeperDoc(new StorekeeperPdfInfo { FileName = model.FileName, - Title = "Список станков", + Title = "Список станков за период", DateFrom = model.DateFrom!.Value, DateTo = model.DateTo!.Value, Machines = GetMachines(client, model) diff --git a/Factory/FactoryBuisinessLogic/OfficePackage/AbstractSaveToPdf.cs b/Factory/FactoryBuisinessLogic/OfficePackage/AbstractSaveToPdf.cs index 7f2d25c..f284f55 100644 --- a/Factory/FactoryBuisinessLogic/OfficePackage/AbstractSaveToPdf.cs +++ b/Factory/FactoryBuisinessLogic/OfficePackage/AbstractSaveToPdf.cs @@ -16,7 +16,7 @@ namespace FactoryBusinessLogic.OfficePackage }); CreateParagraph(new PdfParagraph { - Text = $"с{ info.DateFrom.ToShortDateString() } по { info.DateTo.ToShortDateString() }", Style = "Normal", + Text = $"с { info.DateFrom.ToShortDateString() } по { info.DateTo.ToShortDateString() }", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center }); CreateTable(new List { "3cm", "5cm", "5cm"}); diff --git a/Factory/FactoryBuisinessLogic/OfficePackage/AbstractSaveToWord.cs b/Factory/FactoryBuisinessLogic/OfficePackage/AbstractSaveToWord.cs index 025c707..c0023da 100644 --- a/Factory/FactoryBuisinessLogic/OfficePackage/AbstractSaveToWord.cs +++ b/Factory/FactoryBuisinessLogic/OfficePackage/AbstractSaveToWord.cs @@ -21,21 +21,10 @@ namespace FactoryBusinessLogic.OfficePackage }); foreach (var ppp in info.ProductPlanProductions) { - var t = ppp.PlanProductions; List<(string, WordTextProperties)> texts = new List<(string, WordTextProperties)> { (ppp.ProductName, new WordTextProperties { Bold = true, Size = "24", }) }; - foreach (var plan in ppp.PlanProductions) - { - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.Append(plan.ProductionName); - stringBuilder.Append(" — "); - stringBuilder.Append(plan.Count.ToString()); - stringBuilder.Append(" — "); - stringBuilder.Append(plan.Deadline.ToString()); - texts.Add((stringBuilder.ToString(), new WordTextProperties { Size = "24" })); - } CreateParagraph(new WordParagraph { Texts = texts, @@ -45,6 +34,26 @@ namespace FactoryBusinessLogic.OfficePackage JustificationType = WordJustificationType.Both } }); + foreach (var plan in ppp.PlanProductions) + { + texts = new List<(string, WordTextProperties)>(); + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.Append(plan.ProductionName); + stringBuilder.Append(" — "); + stringBuilder.Append(plan.Count.ToString()); + stringBuilder.Append(" — "); + stringBuilder.Append(plan.Deadline.ToString()); + texts.Add((stringBuilder.ToString(), new WordTextProperties { Size = "24" })); + CreateParagraph(new WordParagraph + { + Texts = texts, + TextProperties = new WordTextProperties + { + Size = "24", + JustificationType = WordJustificationType.Both + } + }); + } } SaveStorekeeperWord(info); } diff --git a/Factory/FactoryStorekeeperApp/Controllers/HomeController.cs b/Factory/FactoryStorekeeperApp/Controllers/HomeController.cs index 34a9256..7678e88 100644 --- a/Factory/FactoryStorekeeperApp/Controllers/HomeController.cs +++ b/Factory/FactoryStorekeeperApp/Controllers/HomeController.cs @@ -415,6 +415,8 @@ namespace FactoryStorekeeperApp.Controllers { return Redirect("~/Home/Enter"); } + ViewBag.DateFrom = datefrom; + ViewBag.DateTo = dateto; var reports = storekeeperReportLogic.GetMachines( new ClientSearchModel { @@ -446,8 +448,51 @@ namespace FactoryStorekeeperApp.Controllers { return Redirect("~/Home/Enter"); } + ViewBag.ids = products; var report = storekeeperReportLogic.GetPlanProductionsByProduct(products); return View(report); + } + + [HttpPost] + public IActionResult CreateWord(List ids) + { + storekeeperReportLogic.SavePlanProductionsToWordFile( + new ReportBindingModel + { + FileName = "D:\\temp\\report.docx" + }, + ids); + return PhysicalFile("D:\\temp\\report.docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "Отчет по изделиям.docx"); + } + + [HttpPost] + public IActionResult CreateExcel(List ids) + { + storekeeperReportLogic.SavePlanProductionsToExcelFile( + new ReportBindingModel + { + FileName = "D:\\temp\\report.xlsx" + }, + ids); + return PhysicalFile("D:\\temp\\report.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Отчет по изделиям.xlsx"); + } + + [HttpPost] + public IActionResult SendMail(DateTime datefrom, DateTime dateto) + { + storekeeperReportLogic.SaveMachinesToPdfFile( + new ClientSearchModel + { + Id = Client.client.Id + }, + new ReportBindingModel + { + DateFrom = datefrom, + DateTo = dateto, + FileName="D:\\temp\\report.pdf" + }); + // TODO: implement sending + throw new NotImplementedException(); } } } diff --git a/Factory/FactoryStorekeeperApp/Views/Home/MachinePeriodReport.cshtml b/Factory/FactoryStorekeeperApp/Views/Home/MachinePeriodReport.cshtml index 53bf257..1d7e432 100644 --- a/Factory/FactoryStorekeeperApp/Views/Home/MachinePeriodReport.cshtml +++ b/Factory/FactoryStorekeeperApp/Views/Home/MachinePeriodReport.cshtml @@ -10,7 +10,9 @@

Список станков за период

-
+ + +
diff --git a/Factory/FactoryStorekeeperApp/Views/Home/PlanProductionByProductReport.cshtml b/Factory/FactoryStorekeeperApp/Views/Home/PlanProductionByProductReport.cshtml index 57e3ca1..5b05d55 100644 --- a/Factory/FactoryStorekeeperApp/Views/Home/PlanProductionByProductReport.cshtml +++ b/Factory/FactoryStorekeeperApp/Views/Home/PlanProductionByProductReport.cshtml @@ -11,9 +11,25 @@
+
+ +
+
+ +
@@ -23,6 +39,8 @@ Изделие План производства + Количество + Срок @@ -38,6 +56,22 @@ } + +
    + @foreach (var plan in product.PlanProductions) + { +
  • @plan.Count
  • + } +
+ + +
    + @foreach (var plan in product.PlanProductions) + { +
  • @plan.Deadline
  • + } +
+ }