diff --git a/LawFim/LawFirmBusinessLogic/OfficePackages/AbstractSaveToExcelVisitsLawyer.cs b/LawFim/LawFirmBusinessLogic/OfficePackages/AbstractSaveToExcelVisitsLawyer.cs index 3eeac85..9cd5941 100644 --- a/LawFim/LawFirmBusinessLogic/OfficePackages/AbstractSaveToExcelVisitsLawyer.cs +++ b/LawFim/LawFirmBusinessLogic/OfficePackages/AbstractSaveToExcelVisitsLawyer.cs @@ -75,6 +75,7 @@ namespace LawFirmBusinessLogic.OfficePackages StyleInfo = ExcelStyleInfoType.Text }); + rowIndex++; } } diff --git a/LawFim/LawFirmGuarantorApp/Controllers/LawyerController.cs b/LawFim/LawFirmGuarantorApp/Controllers/LawyerController.cs index e5162af..91776e0 100644 --- a/LawFim/LawFirmGuarantorApp/Controllers/LawyerController.cs +++ b/LawFim/LawFirmGuarantorApp/Controllers/LawyerController.cs @@ -51,7 +51,7 @@ namespace LawFirmGuarantorApp.Controllers [HttpGet] public IActionResult UpdateLawyer() { - ViewBag.Medicines = APIClient.GetRequest>($"api/lawyer/getlawyerlist?guarantorid={APIClient.Guarantor.Id}"); + ViewBag.Lawyers = APIClient.GetRequest>($"api/lawyer/getlawyerlist?guarantorid={APIClient.Guarantor.Id}"); return View(); } [HttpPost] @@ -73,5 +73,64 @@ namespace LawFirmGuarantorApp.Controllers }); Response.Redirect("/Home/Lawyers"); } - } + + [HttpGet] + public IActionResult GetFile() + { + ViewBag.Lawyers = APIClient.GetRequest>($"api/lawyer/getlawyerlist?guarantorid={APIClient.Guarantor.Id}"); + + return View(); + } + + [HttpPost] + public void GetFile(int lawyerId, string type) + { + if (APIClient.Guarantor == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + + if (lawyerId == 0) + { + throw new Exception("Выберите юриста"); + } + + if (string.IsNullOrEmpty(type)) + { + throw new Exception("Неверный тип отчета"); + } + + if (type == "docx") + { + APIClient.PostRequest("api/reportguarantor/savevisitlawyertowordfile", new ReportVisitLawyerBindingModel + { + LawyerId = lawyerId, + //FileName = "D:\\CourseWork\\wordfileTest.docx", + GuarantorId= APIClient.Guarantor.Id + }); + Response.Redirect("GetWordFile"); + } + else + { + APIClient.PostRequest("api/reportguarantor/savevisitlawyertoexcelfile", new ReportVisitLawyerBindingModel + { + LawyerId = lawyerId, + GuarantorId = APIClient.Guarantor.Id + //FileName = "D:\\CourseWork\\excelfileTest.xlsx" + }); + Response.Redirect("GetExcelFile"); + } + } + + [HttpGet] + public IActionResult GetWordFile() + { + return new PhysicalFileResult("D:\\CourseWork\\wordVisitLawyerReport.docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"); + } + + public IActionResult GetExcelFile() + { + return new PhysicalFileResult("D:\\CourseWork\\excelVisitLawyerReport.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + } + } } diff --git a/LawFim/LawFirmGuarantorApp/Controllers/ReportController.cs b/LawFim/LawFirmGuarantorApp/Controllers/ReportController.cs new file mode 100644 index 0000000..f9dad88 --- /dev/null +++ b/LawFim/LawFirmGuarantorApp/Controllers/ReportController.cs @@ -0,0 +1,110 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.ViewModels; +using Microsoft.AspNetCore.Mvc; +using System.Globalization; + +namespace LawFirmGuarantorApp.Controllers +{ + public class ReportController : Controller + { + private readonly ILogger _logger; + + public ReportController(ILogger logger) + { + _logger = logger; + } + [HttpGet] + public IActionResult Report() + { + ViewBag.Report = new List(); + return View(); + } + + [HttpGet] + public string GetReport(DateTime dateFrom, DateTime dateTo) + { + if (APIClient.Guarantor == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + List result; + try + { + string dateFromS = dateFrom.ToString("s", CultureInfo.InvariantCulture); + string dateToS = dateTo.ToString("s", CultureInfo.InvariantCulture); + result = APIClient.GetRequest> + ($"api/reportguarantor/getconsultationhearingreport?datefrom={dateFromS}&dateto={dateToS}&guarantorid={APIClient.Guarantor.Id}")!; + + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания отчета"); + throw; + } + string table = ""; + table += "

Предварительный отчет

"; + table += "
"; + table += ""; + table += ""; + table += ""; + table += ""; + table += ""; + table += ""; + table += ""; + table += ""; + table += ""; + foreach (var medicine in result) + { + table += ""; + table += ""; + table += $""; + table += $""; + table += $""; + table += $""; + table += ""; + foreach (var guidance in medicine.Hearing) + { + table += ""; + table += $""; + table += $""; + table += $""; + table += $""; + table += ""; + } + foreach (var visit in medicine.Case) + { + table += ""; + table += $""; + table += $""; + table += $""; + table += $""; + table += ""; + } + table += ""; + } + table += "
ДатаНазвание медикаментаУслуга рекомендацииНазвание визита
{medicine.LawyerName}
{guidance.HearingDate}{guidance.HearingDate}
{visit.CaseName}{visit.CaseType}
"; + table += "
"; + return table; + } + + [HttpPost] + public void Report(DateTime dateFrom, DateTime dateTo) + { + if (APIClient.Guarantor == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + APIClient.PostRequest("api/reportguarantor/mailsend", new ReportCaseHearingBindingModel + { + FileName = "D:\\CourseWork\\pdffiletest.pdf", + GuarantorId = APIClient.Guarantor.Id, + DateFrom = dateFrom, + DateTo = dateTo, + Email = APIClient.Guarantor.Email + + }); + Response.Redirect("Report"); + + } + } +} diff --git a/LawFim/LawFirmGuarantorApp/Views/Home/Lawyers.cshtml b/LawFim/LawFirmGuarantorApp/Views/Home/Lawyers.cshtml index a9a4e70..d6b78ef 100644 --- a/LawFim/LawFirmGuarantorApp/Views/Home/Lawyers.cshtml +++ b/LawFim/LawFirmGuarantorApp/Views/Home/Lawyers.cshtml @@ -69,5 +69,13 @@ } + + +
+ +
+ + + } \ No newline at end of file diff --git a/LawFim/LawFirmGuarantorApp/Views/Home/Report.cshtml b/LawFim/LawFirmGuarantorApp/Views/Home/Report.cshtml new file mode 100644 index 0000000..240a9a4 --- /dev/null +++ b/LawFim/LawFirmGuarantorApp/Views/Home/Report.cshtml @@ -0,0 +1,65 @@ +@{ + ViewData["Title"] = "Report"; +} + +
+
+

Отчет по консультациям и слушаниям за период

+
+ +
+
+
+
+ + +
+
+
+
+ + +
+
+
+ +
+
+
+ +
+
+ +
+
+
+ +
+
+ +
+
+
+ +@section Scripts { + +} \ No newline at end of file diff --git a/LawFim/LawFirmGuarantorApp/Views/Lawyer/GetFile.cshtml b/LawFim/LawFirmGuarantorApp/Views/Lawyer/GetFile.cshtml new file mode 100644 index 0000000..67dea2a --- /dev/null +++ b/LawFim/LawFirmGuarantorApp/Views/Lawyer/GetFile.cshtml @@ -0,0 +1,31 @@ +@using LawFirmContracts.ViewModels; + +@{ + ViewData["Title"] = "Визиты по юристам"; +} + +
+

Создать списки визитов по юристам

+
+
+
+
Юрист:
+
+ +
+
+
+ +
+ + +
+
+ + +
+
+
+ +
+
diff --git a/LawFim/LawFirmGuarantorApp/Views/Shared/_Layout.cshtml b/LawFim/LawFirmGuarantorApp/Views/Shared/_Layout.cshtml index f16ed2c..03338cd 100644 --- a/LawFim/LawFirmGuarantorApp/Views/Shared/_Layout.cshtml +++ b/LawFim/LawFirmGuarantorApp/Views/Shared/_Layout.cshtml @@ -31,6 +31,9 @@ +