я в шоке документы делаются и сохраняются!
This commit is contained in:
parent
563fb6fa31
commit
c9460bcb99
@ -75,6 +75,7 @@ namespace LawFirmBusinessLogic.OfficePackages
|
||||
StyleInfo =
|
||||
ExcelStyleInfoType.Text
|
||||
});
|
||||
rowIndex++;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ namespace LawFirmGuarantorApp.Controllers
|
||||
[HttpGet]
|
||||
public IActionResult UpdateLawyer()
|
||||
{
|
||||
ViewBag.Medicines = APIClient.GetRequest<List<LawyerViewModel>>($"api/lawyer/getlawyerlist?guarantorid={APIClient.Guarantor.Id}");
|
||||
ViewBag.Lawyers = APIClient.GetRequest<List<LawyerViewModel>>($"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<List<LawyerViewModel>>($"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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
110
LawFim/LawFirmGuarantorApp/Controllers/ReportController.cs
Normal file
110
LawFim/LawFirmGuarantorApp/Controllers/ReportController.cs
Normal file
@ -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<ReportController> _logger;
|
||||
|
||||
public ReportController(ILogger<ReportController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult Report()
|
||||
{
|
||||
ViewBag.Report = new List<ReportCaseHearingBindingModel>();
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public string GetReport(DateTime dateFrom, DateTime dateTo)
|
||||
{
|
||||
if (APIClient.Guarantor == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
List<ReportCaseHearingViewModel> result;
|
||||
try
|
||||
{
|
||||
string dateFromS = dateFrom.ToString("s", CultureInfo.InvariantCulture);
|
||||
string dateToS = dateTo.ToString("s", CultureInfo.InvariantCulture);
|
||||
result = APIClient.GetRequest<List<ReportCaseHearingViewModel>>
|
||||
($"api/reportguarantor/getconsultationhearingreport?datefrom={dateFromS}&dateto={dateToS}&guarantorid={APIClient.Guarantor.Id}")!;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания отчета");
|
||||
throw;
|
||||
}
|
||||
string table = "";
|
||||
table += "<h2 class=\"text-custom-color-1\">Предварительный отчет</h2>";
|
||||
table += "<div class=\"table-responsive\">";
|
||||
table += "<table class=\"table table-striped table-bordered table-hover\">";
|
||||
table += "<thead class=\"table-dark\">";
|
||||
table += "<tr>";
|
||||
table += "<th scope=\"col\">Дата</th>";
|
||||
table += "<th scope=\"col\">Название медикамента</th>";
|
||||
table += "<th scope=\"col\">Услуга рекомендации</th>";
|
||||
table += "<th scope=\"col\">Название визита</th>";
|
||||
table += "</tr>";
|
||||
table += "</thead>";
|
||||
foreach (var medicine in result)
|
||||
{
|
||||
table += "<tbody>";
|
||||
table += "<tr>";
|
||||
table += $"<td></td>";
|
||||
table += $"<td>{medicine.LawyerName}</td>";
|
||||
table += $"<td></td>";
|
||||
table += $"<td></td>";
|
||||
table += "</tr>";
|
||||
foreach (var guidance in medicine.Hearing)
|
||||
{
|
||||
table += "<tr>";
|
||||
table += $"<td>{guidance.HearingDate}</td>";
|
||||
table += $"<td></td>";
|
||||
table += $"<td>{guidance.HearingDate}</td>";
|
||||
table += $"<td></td>";
|
||||
table += "</tr>";
|
||||
}
|
||||
foreach (var visit in medicine.Case)
|
||||
{
|
||||
table += "<tr>";
|
||||
table += $"<td>{visit.CaseName}</td>";
|
||||
table += $"<td></td>";
|
||||
table += $"<td></td>";
|
||||
table += $"<td>{visit.CaseType}</td>";
|
||||
table += "</tr>";
|
||||
}
|
||||
table += "</tbody>";
|
||||
}
|
||||
table += "</table>";
|
||||
table += "</div>";
|
||||
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");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -69,5 +69,13 @@
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<tr>
|
||||
<td>
|
||||
<form action="/Lawyer/GetFile">
|
||||
<button type="submit" class="btn btn-danger">Получить docx/xlsx файл</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
}
|
||||
</div>
|
65
LawFim/LawFirmGuarantorApp/Views/Home/Report.cshtml
Normal file
65
LawFim/LawFirmGuarantorApp/Views/Home/Report.cshtml
Normal file
@ -0,0 +1,65 @@
|
||||
@{
|
||||
ViewData["Title"] = "Report";
|
||||
}
|
||||
|
||||
<div class="container">
|
||||
<div class="text-center mb-4">
|
||||
<h2 class="text-custom-color-1">Отчет по консультациям и слушаниям за период</h2>
|
||||
</div>
|
||||
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="dateFrom" class="form-label text-custom-color-1">Начало периода:</label>
|
||||
<input type="datetime-local" id="dateFrom" name="dateFrom" class="form-control" placeholder="Выберите дату начала периода">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label for="dateTo" class="form-label text-custom-color-1">Окончание периода:</label>
|
||||
<input type="datetime-local" id="dateTo" name="dateTo" class="form-control" placeholder="Выберите дату окончания периода">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-4">
|
||||
<div class="col-md-8"></div>
|
||||
<div class="col-md-4">
|
||||
<button type="submit" class="btn btn-outline-dark w-100 text-center d-flex justify-content-md-center">Отправить на почту</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-4">
|
||||
<div class="col-md-8"></div>
|
||||
<div class="col-md-4">
|
||||
<button type="button" id="demonstrate" class="btn btn-outline-dark w-100 text-center d-flex justify-content-md-center">Продемонстрировать</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="report"></div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
<script>
|
||||
function check() {
|
||||
var dateFrom = $('#dateFrom').val();
|
||||
var dateTo = $('#dateTo').val();
|
||||
if (dateFrom && dateTo) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetReport",
|
||||
data: { dateFrom: dateFrom, dateTo: dateTo },
|
||||
success: function (result) {
|
||||
if (result != null) {
|
||||
$('#report').html(result);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
check();
|
||||
$('#demonstrate').on('click', (e) => check());
|
||||
</script>
|
||||
}
|
31
LawFim/LawFirmGuarantorApp/Views/Lawyer/GetFile.cshtml
Normal file
31
LawFim/LawFirmGuarantorApp/Views/Lawyer/GetFile.cshtml
Normal file
@ -0,0 +1,31 @@
|
||||
@using LawFirmContracts.ViewModels;
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Визиты по юристам";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Создать списки визитов по юристам</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Юрист:</div>
|
||||
<div class="col-8">
|
||||
<select id="lawyerId" name="lawyerId" class="form-control" asp-items="@(new SelectList(@ViewBag.Lawyers,"Id", "FIO"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="file-format">
|
||||
<label class="form-label">Выберите формат файла:</label>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="type" value="docx" id="docx">
|
||||
<label class="form-check-label" for="docx">Word-файл</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="radio" name="type" value="xlsx" id="xlsx" checked>
|
||||
<label class="form-check-label" for="xlsx">Excel-файл</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex justify-content-center">
|
||||
<button type="submit" class="btn btn-block btn-outline-dark w-100">Создать</button>
|
||||
</div>
|
||||
</form>
|
@ -31,6 +31,9 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="PrivacyGuarantor">Личные данные</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Report">Отчеты</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="RegisterGuarantor">Регистрация</a>
|
||||
</li>
|
||||
|
Loading…
x
Reference in New Issue
Block a user