Скачивание отчёта

This commit is contained in:
dimazhelovanov 2023-05-24 16:42:06 +04:00
parent c9baa15703
commit a31f4e994f
4 changed files with 95 additions and 8 deletions

View File

@ -24,8 +24,36 @@ namespace LawFirmClientApp.Controllers
Response.Redirect("CreateReportClients");
}*/
[HttpGet]
[HttpPost]
public void LoadReportClients(DateTime dateFrom, DateTime dateTo)
{
if (APIClient.User == null)
{
Redirect("~/Home/Enter");
}
APIClient.PostRequest($"api/report/saveclientspdffile", new ReportBindingModel
{
DateFrom = dateFrom,
DateTo = dateTo,
CompanyId = APIClient.User.CompanyId
});
}
[HttpGet]
public IActionResult LoadReportClients(DateTime dateFrom, DateTime dateTo, string a)
{
if (APIClient.User == null)
{
return Redirect("~/Home/Enter");
}
return View(APIClient.GetRequest<List<ReportClientsViewModel>>($"api/report/getclientsreport?datefrom={dateFrom}&dateTo={dateTo}&companyId={APIClient.User.CompanyId}"));
}
[HttpGet]
public IActionResult CreateReportClients(DateTime dateFrom, DateTime dateTo)
{
if (APIClient.User == null)

View File

@ -5,13 +5,19 @@
ViewData["Title"] = "Отчёт по клиентам";
Layout = "~/Views/Shared/_LayoutIspol.cshtml";
}
div class="text-center">
<h1 class="display-4">Мои дела</h1>
<head>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<div class="text-center">
<h1 class="display-4">Отчёт по клиентам</h1>
</div>
<div class="text-center">
@{
<form action="/Report/CreateReportClients" method="get">
<button type="submit" class="btn btn-danger">Получить отчет</button>
<button id="loadButton">Load Report Clients</button>
<div class="row">
<div class="col-4">От</div>
@ -25,9 +31,9 @@ div class="text-center">
</div>
</form>
<table class="table">
<thead>
@ -74,4 +80,57 @@ div class="text-center">
</tbody>
</table>
}
</div>
</div>
<script>
$(document).ready(function () {
$('#formDownload').submit(function (e) {
e.preventDefault(); // Предотвращаем отправку формы по умолчанию
var dateto = $('#dateTo').val(); // Получаем значение поля dateto
var datefrom = $('#dateFrom').val(); // Получаем значение поля datefrom
// Выполняем AJAX-запрос
$.ajax({
url: '/Report/CreateReportClients', // Замените на URL вашего обработчика формы
type: 'POST', // Или 'GET', в зависимости от типа запроса
data: {
dateto: dateto,
datefrom: datefrom
},
success: function (response) {
// Обработка успешного ответа
console.log(response);
},
error: function (xhr, status, error) {
// Обработка ошибки
console.error(error);
}
});
});
});
</script>
<script>
$(document).ready(function () {
$('#loadButton').click(function () {
var dateTo = $('#dateTo').val();
var dateFrom = $('#dateFrom').val();
// Выполняем AJAX-запрос
$.ajax({
url: '/Report/LoadReportClients', // Замените на URL вашего метода контроллера
type: 'POST', // Или 'POST', в зависимости от типа запроса
data: {
dateTo: dateTo,
dateFrom: dateFrom
},
success: function (response) {
// Обработка успешного ответа
console.log(response);
},
error: function (xhr, status, error) {
// Обработка ошибки
console.error(error);
}
});
});
});
</script>

View File

@ -32,7 +32,7 @@
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="PrivacyLawyer">Личные данные</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Report" asp-action="CreateReportClients">Юристы</a>
<a class="nav-link text-dark" asparea="" asp-controller="Report" asp-action="CreateReportClients">Отчёт по сотрудникам</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="RegisterLawyer">Регистрация</a>

View File

@ -25,7 +25,7 @@ builder.Services.AddTransient<IConsultationStorage, ConsultationStorage>();
builder.Services.AddTransient<ILawyerStorage, LawyerStorage>();
builder.Services.AddTransient<IHearingStorage, HearingStorage>();
builder.Services.AddTransient<IClientModel, ClientBindingModel>();
builder.Services.AddTransient<ICaseLogic, CaseLogic>();
builder.Services.AddTransient<IVisitLogic, VisitLogic>();
builder.Services.AddTransient<IClientLogic, ClientLogic>();