Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
c3a2e129df |
@ -1,12 +1,10 @@
|
||||
using CaseAccountingBusinessLogic.BusinessLogic.OfficePackage;
|
||||
using CaseAccountingBusinessLogic.OfficePackage;
|
||||
using CaseAccountingBusinessLogic.OfficePackage;
|
||||
using CaseAccountingBusinessLogic.OfficePackage.HelperModels;
|
||||
using CaseAccountingContracts.BindingModels;
|
||||
using CaseAccountingContracts.BusinessLogicContracts;
|
||||
using CaseAccountingContracts.SearchModels;
|
||||
using CaseAccountingContracts.StoragesContracts;
|
||||
using CaseAccountingContracts.ViewModels;
|
||||
using CaseAccountingDataBaseImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -23,11 +21,9 @@ namespace CaseAccountingBusinessLogic.BusinessLogics
|
||||
private readonly ISpecializationStorage _specializationStorage;
|
||||
private readonly WordBuilderCustomer _wordBuilder;
|
||||
private readonly ExcelBuilderCustomer _excelBuilder;
|
||||
private readonly PdfBuilderCustomer _pdfBuilder;
|
||||
private readonly MailSender _mailSender;
|
||||
|
||||
public ReportCustomerLogic(ICaseStorage caseStorage, IHearingStorage hearingStorage, ILawyerStorage lawyerStorage, ISpecializationStorage specializationStorage,
|
||||
WordBuilderCustomer wordBuilder, ExcelBuilderCustomer excelBuilder, PdfBuilderCustomer pdfBuilder, MailSender mailSender)
|
||||
WordBuilderCustomer wordBuilder, ExcelBuilderCustomer excelBuilder)
|
||||
{
|
||||
_caseStorage = caseStorage;
|
||||
_hearingStorage = hearingStorage;
|
||||
@ -35,16 +31,9 @@ namespace CaseAccountingBusinessLogic.BusinessLogics
|
||||
_specializationStorage = specializationStorage;
|
||||
_wordBuilder = wordBuilder;
|
||||
_excelBuilder = excelBuilder;
|
||||
_pdfBuilder = pdfBuilder ?? throw new ArgumentNullException(nameof(pdfBuilder));
|
||||
_mailSender = mailSender ?? throw new ArgumentNullException(nameof(mailSender));
|
||||
}
|
||||
|
||||
public List<ReportHearingSpecializationViewModel> GetHearingSpecialization(ReportBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/*public List<ReportHearingSpecializationViewModel> GetHearingSpecialization(ReportBindingModel model)
|
||||
{
|
||||
var result = _hearingStorage
|
||||
.GetFilteredList(new HearingSearchModel { UserId = model.UserId })
|
||||
@ -61,29 +50,40 @@ namespace CaseAccountingBusinessLogic.BusinessLogics
|
||||
})
|
||||
.ToList();
|
||||
return result;
|
||||
}*/
|
||||
}
|
||||
|
||||
public List<ReportLawyerHearingViewModel> GetLawyersHearing(List<LawyerViewModel> lawyers)
|
||||
{
|
||||
List <ReportLawyerHearingViewModel> list = new();
|
||||
var reportRecords = new List<ReportLawyerHearingViewModel>();
|
||||
foreach (var lawyer in lawyers)
|
||||
{
|
||||
ReportLawyerHearingViewModel report = new ReportLawyerHearingViewModel
|
||||
var hearings = _lawyerStorage.GetLawyerCases(new() { Id = lawyer.Id })
|
||||
.SelectMany(_case => _caseStorage.GetCaseHearings(new() { Id = _case.Id }))
|
||||
.Select(hearing => hearing.Information)
|
||||
.ToList();
|
||||
ReportLawyerHearingViewModel reportRecord = new()
|
||||
{
|
||||
Lawyer = lawyer.Surname + " " + lawyer.Name + " " + lawyer.Patronymic,
|
||||
Hearings = new()
|
||||
Lawyer = lawyer.Name + " " + lawyer.Surname + ", " + lawyer.Patronymic,
|
||||
Hearings = hearings
|
||||
};
|
||||
var cases = _caseStorage.GetCaseMTM(lawyer.Id);
|
||||
foreach (var caseModel in cases)
|
||||
reportRecords.Add(reportRecord);
|
||||
}
|
||||
return reportRecords;
|
||||
}
|
||||
|
||||
public void SaveHearingSpecializationToPdfFile(ReportBindingModel model)
|
||||
{
|
||||
foreach (var hearing in _hearingStorage.GetFilteredList(new HearingSearchModel { CaseId = caseModel.Id }))
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SaveLawyerHearingToExcelFile(ReportBindingModel model)
|
||||
{
|
||||
report.Hearings.Add("Номер слушания: " + hearing.Id.ToString());
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
list.Add(report);
|
||||
}
|
||||
return list;
|
||||
|
||||
public void SaveLawyerHearingToWordFile(ReportBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public byte[] SaveListFile(LawyerHearingListBindingModel model)
|
||||
@ -108,67 +108,5 @@ namespace CaseAccountingBusinessLogic.BusinessLogics
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
public void SendByMailStatusReport(ReportBindingModel reportModel)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/*public List<ReportHearingSpecializationViewModel> GetHearingSpecialization(ReportBindingModel model)
|
||||
{
|
||||
var hearings = _hearingStorage.GetFilteredList(new HearingSearchModel
|
||||
{
|
||||
DateFrom = model.DateFrom,
|
||||
DateTo = model.DateTo
|
||||
});
|
||||
|
||||
var casesIds = hearings.Select(x => x.CaseId).ToList();
|
||||
|
||||
var cases = _caseStorage.GetFullList().Where(x => casesIds.Contains(x.Id));
|
||||
|
||||
List<SpecializationViewModel> specializations = new List<SpecializationViewModel>();
|
||||
|
||||
foreach (var _case in cases)
|
||||
{
|
||||
specializations.Add(_specializationStorage.GetElement(new SpecializationSearchModel { Id = _case.Id }));
|
||||
}
|
||||
|
||||
*//*var reportRecords = new List<ReportHearingSpecializationViewModel>();
|
||||
|
||||
foreach (var _case in cases)
|
||||
{
|
||||
ReportHearingSpecializationViewModel reportData = new ReportHearingSpecializationViewModel();
|
||||
reportData.Name = _case.Name;
|
||||
|
||||
var hearings = _caseStorage.GetCaseHearing(new() { Id = _case.Id });
|
||||
|
||||
var specialization = _caseStorage.GetCaseSpecialization(new() { Id = _case.Id });
|
||||
|
||||
reportData.hearings = hearings;
|
||||
reportData.Specialization = specialization.Name;
|
||||
reportRecords.Add(reportData);
|
||||
}*//*
|
||||
|
||||
//return reportRecords;
|
||||
}*/
|
||||
|
||||
/*public void SendByMailStatusReport(ReportBindingModel reportModel)
|
||||
{
|
||||
byte[] file = _pdfBuilder.GetHearingSpecializationReportFile(new()
|
||||
{
|
||||
Title = "Отчет по слушаниям",
|
||||
DateFrom = reportModel.DateFrom,
|
||||
DateTo = reportModel.DateTo,
|
||||
Records = GetHearingSpecialization(reportModel)
|
||||
});
|
||||
_mailSender.SendMailAsync(new()
|
||||
{
|
||||
MailAddress = reportModel.UserEmail,
|
||||
Subject = "Отчет по слушаниям",
|
||||
Text = $"За период с {reportModel.DateFrom.ToShortDateString()} " +
|
||||
$"по {reportModel.DateTo.ToShortDateString()}.",
|
||||
File = file
|
||||
});
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,12 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="OfficePackage\Implements\**" />
|
||||
<EmbeddedResource Remove="OfficePackage\Implements\**" />
|
||||
<None Remove="OfficePackage\Implements\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DocumentFormat.OpenXml" Version="2.20.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
|
||||
|
@ -1,187 +0,0 @@
|
||||
using CaseAccountingBusinessLogic.OfficePackage.HelperEnums;
|
||||
using CaseAccountingBusinessLogic.OfficePackage.HelperModels;
|
||||
using CaseAccountingContracts.ViewModels;
|
||||
using MigraDoc.DocumentObjectModel;
|
||||
using MigraDoc.Rendering;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using MigraDoc.DocumentObjectModel.Tables;
|
||||
|
||||
namespace CaseAccountingBusinessLogic.OfficePackage
|
||||
{
|
||||
public class PdfBuilderCustomer
|
||||
{
|
||||
private readonly string tempFileName = "temp.pdf";
|
||||
private Document? document;
|
||||
private Section? section;
|
||||
private Table? table;
|
||||
|
||||
private static ParagraphAlignment GetParagraphAlignment(PdfParagraphAlignmentType type)
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
PdfParagraphAlignmentType.Center => ParagraphAlignment.Center,
|
||||
PdfParagraphAlignmentType.Left => ParagraphAlignment.Left,
|
||||
_ => ParagraphAlignment.Justify,
|
||||
};
|
||||
}
|
||||
|
||||
private void DefineStyles(Document document)
|
||||
{
|
||||
var style = document.Styles["Normal"];
|
||||
style.Font.Name = "Times New Roman";
|
||||
style.Font.Size = 14;
|
||||
|
||||
style = document.Styles.AddStyle("NormalTitle", "Normal");
|
||||
style.Font.Bold = true;
|
||||
}
|
||||
|
||||
public void CreateDocument()
|
||||
{
|
||||
document = new Document();
|
||||
DefineStyles(document);
|
||||
section = document.AddSection();
|
||||
}
|
||||
|
||||
public void CreateParagraph(PdfParagraph pdfParagraph)
|
||||
{
|
||||
if (section == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var paragraph = section.AddParagraph(pdfParagraph.Text);
|
||||
paragraph.Format.SpaceAfter = "1cm";
|
||||
paragraph.Format.Alignment = GetParagraphAlignment(pdfParagraph.ParagraphAlignment);
|
||||
paragraph.Style = pdfParagraph.Style;
|
||||
}
|
||||
|
||||
public void CreateTable(List<string> columns)
|
||||
{
|
||||
if (document == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
table = document.LastSection.AddTable();
|
||||
foreach (var elem in columns)
|
||||
{
|
||||
table.AddColumn(elem);
|
||||
}
|
||||
}
|
||||
|
||||
public void CreateRow(PdfRowParameters rowParameters)
|
||||
{
|
||||
if (table == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var row = table.AddRow();
|
||||
for (int i = 0; i < rowParameters.Texts.Count; ++i)
|
||||
{
|
||||
row.Cells[i].AddParagraph(rowParameters.Texts[i]);
|
||||
if (!string.IsNullOrEmpty(rowParameters.Style))
|
||||
{
|
||||
row.Cells[i].Style = rowParameters.Style;
|
||||
}
|
||||
Unit borderWidth = 0.5;
|
||||
row.Cells[i].Borders.Left.Width = borderWidth;
|
||||
row.Cells[i].Borders.Right.Width = borderWidth;
|
||||
row.Cells[i].Borders.Top.Width = borderWidth;
|
||||
row.Cells[i].Borders.Bottom.Width = borderWidth;
|
||||
row.Cells[i].Format.Alignment = GetParagraphAlignment(rowParameters.ParagraphAlignment);
|
||||
row.Cells[i].VerticalAlignment = VerticalAlignment.Center;
|
||||
}
|
||||
}
|
||||
|
||||
private void Save()
|
||||
{
|
||||
|
||||
// Регистрация провайдера кодировки для кодировки 1252, без этого ошибОчка была
|
||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||
|
||||
var renderer = new PdfDocumentRenderer(true)
|
||||
{
|
||||
Document = document
|
||||
};
|
||||
renderer.RenderDocument();
|
||||
renderer.PdfDocument.Save(tempFileName);
|
||||
}
|
||||
|
||||
public byte[] GetFile()
|
||||
{
|
||||
Save();
|
||||
byte[] file = File.ReadAllBytes(tempFileName);
|
||||
File.Delete(tempFileName);
|
||||
return file;
|
||||
}
|
||||
|
||||
/*public byte[] GetHearingSpecializationReportFile(PdfData<ReportHearingSpecializationViewModel> data)
|
||||
{
|
||||
CreateDocument();
|
||||
|
||||
CreateParagraph(new PdfParagraph
|
||||
{
|
||||
Text = data.Title,
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
|
||||
CreateParagraph(new PdfParagraph
|
||||
{
|
||||
Text = $"за период с {data.DateFrom.ToShortDateString()} " +
|
||||
$"по {data.DateTo.ToShortDateString()}",
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
|
||||
CreateTable(new List<string> { "4cm", "2cm", "4cm", "2cm", "4cm" });
|
||||
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { "Продукт", "Блюдо", "Дата заказа", "Напиток", "Дата заказа" },
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
|
||||
foreach (var record in data.Records)
|
||||
{
|
||||
List<HearingViewModel> hearings = record.hearings;
|
||||
string specialization = record.Specialization;
|
||||
int recordHeight = Math.Max(hearings.Count + 1, 1);
|
||||
for (int i = 0; i < recordHeight; i++)
|
||||
{
|
||||
List<string> cellsData = new() { "", "", "", "", "" };
|
||||
if (i == 0)
|
||||
{
|
||||
cellsData[0] = record.Information;
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = cellsData,
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||
});
|
||||
continue;
|
||||
}
|
||||
int k = i - 1;
|
||||
if (k < hearings.Count)
|
||||
{
|
||||
cellsData[1] = hearings[k].Id.ToString();
|
||||
cellsData[2] = hearings[k].Date.ToString();
|
||||
}
|
||||
cellsData[3] = specialization;
|
||||
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = cellsData,
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return GetFile();
|
||||
}*/
|
||||
}
|
||||
}
|
@ -16,6 +16,10 @@ namespace CaseAccountingContracts.BusinessLogicContracts
|
||||
|
||||
byte[] SaveListFile(LawyerHearingListBindingModel model);
|
||||
|
||||
void SendByMailStatusReport(ReportBindingModel reportModel);
|
||||
void SaveLawyerHearingToWordFile(ReportBindingModel model);
|
||||
|
||||
void SaveLawyerHearingToExcelFile(ReportBindingModel model);
|
||||
|
||||
void SaveHearingSpecializationToPdfFile(ReportBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -21,9 +21,5 @@ namespace CaseAccountingContracts.SearchModels
|
||||
public int? SpecializationId { get; set; }
|
||||
|
||||
public int? UserId { get; set; }
|
||||
|
||||
public DateTime? DateFrom { get; set; }
|
||||
|
||||
public DateTime? DateTo { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -15,8 +15,5 @@ namespace CaseAccountingContracts.SearchModels
|
||||
public int? CaseId { get; set; }
|
||||
|
||||
public int? UserId { get; set; }
|
||||
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -18,11 +18,7 @@ namespace CaseAccountingContracts.StoragesContracts
|
||||
CaseViewModel? Update(CaseBindingModel model);
|
||||
CaseViewModel? Delete(CaseBindingModel model);
|
||||
|
||||
List<HearingViewModel> GetCaseHearing(CaseSearchModel model);
|
||||
|
||||
SpecializationViewModel GetCaseSpecialization(SpecializationSearchModel model);
|
||||
|
||||
List<CaseViewModel> GetCaseMTM(int lawyerId);
|
||||
List<HearingViewModel> GetCaseHearings(CaseSearchModel model);
|
||||
List<SpecializationCasesViewModel>? GetSpecializationCases();
|
||||
}
|
||||
}
|
||||
|
@ -9,10 +9,10 @@ namespace CaseAccountingContracts.ViewModels
|
||||
{
|
||||
public class ReportHearingSpecializationViewModel
|
||||
{
|
||||
public string Information { get; set; } = string.Empty;
|
||||
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
public string Specialization { get; set; } = string.Empty;
|
||||
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
public List<HearingViewModel> hearings { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -6,10 +6,6 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Remove="wwwroot\js\Report\reportlist.js~RF3ae78116.TMP" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
@ -102,7 +102,7 @@ namespace CaseAccountingCustomerView.Controllers
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public int[]? HearingLawyerlist([FromBody] LawyerHearingListBindingModel listModel)
|
||||
public int[]? HearingLawyerList([FromBody] LawyerHearingListBindingModel listModel)
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
@ -117,24 +117,5 @@ namespace CaseAccountingCustomerView.Controllers
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult GetReport()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public List<ReportHearingSpecializationViewModel>? GetReport([FromBody] ReportBindingModel reportModel)
|
||||
{
|
||||
if (APIUser.User == null)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
reportModel.UserId = APIUser.User.Id;
|
||||
reportModel.UserEmail = APIUser.User.Login;
|
||||
List<ReportHearingSpecializationViewModel>? list = APIUser.PostRequestWithResult<ReportBindingModel, List<ReportHearingSpecializationViewModel>>
|
||||
("api/reportcustomer/getreportdata", reportModel);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
@{
|
||||
ViewData["Title"] = "Отчет";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Отчет по слушаниям</h1>
|
||||
</div>
|
||||
|
||||
<div id="error-div-shell" class="error-div-shell mb-2">
|
||||
<div>
|
||||
<p id="error-p" class="error-p"></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex flex-wrap gap-1 align-items-end mb-2">
|
||||
<div class="mb-2">
|
||||
<p class="mb-0">Дата начала:</p>
|
||||
<input id="date-from-input" class="form-control" type="date" />
|
||||
</div>
|
||||
<div class="mb-2">
|
||||
<p class="mb-0">Дата конца:</p>
|
||||
<input id="date-to-input" class="form-control" type="date" />
|
||||
</div>
|
||||
<button id="generate-button" class="btn btn-primary mb-2">
|
||||
Показать
|
||||
</button>
|
||||
<button id="send-by-mail-button" class="btn btn-primary mb-2">
|
||||
На почту
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<p class="mb-0">
|
||||
<span>За период с </span>
|
||||
<span id="date-from-span" class="fw-bold">...</span>
|
||||
<span> по </span>
|
||||
<span id="date-to-span" class="fw-bold">...</span>
|
||||
</p>
|
||||
<div class="table-shell mb-2 border">
|
||||
<table class="table mb-0">
|
||||
<thead class="table-head">
|
||||
<tr>
|
||||
<th>Номер слушания</th>
|
||||
<th>Дело</th>
|
||||
<th>Дата проведения</th>
|
||||
<th>Специализация</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="tbody">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="table"></div>
|
||||
|
||||
<script src="~/js/Report/reportpdf.js" asp-append-version="true"></script>
|
@ -7,31 +7,15 @@ var dataArray = [];
|
||||
const wordMIME = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
|
||||
const excelMIME = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
||||
|
||||
window.addEventListener('load', async () => {
|
||||
try {
|
||||
await $.ajax({
|
||||
url: `/lawyers/getallbyuser`,
|
||||
window.addEventListener('load', () => {
|
||||
$.ajax({
|
||||
url: "/lawyers/getallbyuser",
|
||||
type: "GET",
|
||||
contentType: "json"
|
||||
}).done((result) => {
|
||||
lawyers = result;
|
||||
lawyers.forEach((lawyerModel) => {
|
||||
const { id, name, surname, patronymic, experience, specialization } = lawyerModel;
|
||||
const row = tbody.insertRow();
|
||||
row.setAttribute("data-id", id);
|
||||
|
||||
const cells = [name, surname, patronymic, experience, specialization];
|
||||
cells.forEach((value) => {
|
||||
const cell = row.insertCell();
|
||||
cell.textContent = value;
|
||||
lawyers.forEach((lawyer) => createRowForLawyersTable(lawyer));
|
||||
});
|
||||
|
||||
row.addEventListener('click', () => addAndRemoveFromList(row));
|
||||
});
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
})
|
||||
|
||||
createBtn.addEventListener('click', () => {
|
||||
@ -39,6 +23,7 @@ createBtn.addEventListener('click', () => {
|
||||
"Lawyers": Array.from(dataArray),
|
||||
"FileType": fileType.value
|
||||
};
|
||||
console.log(listModel);
|
||||
$.ajax({
|
||||
url: "/home/hearinglawyerlist",
|
||||
type: "POST",
|
||||
@ -76,16 +61,38 @@ const saveFile = async function (bytes, fileType) {
|
||||
}
|
||||
}
|
||||
|
||||
const createRowForLawyersTable = (lawyer) => {
|
||||
const { id, name, surname, patronymic, experience, specialization } = lawyer;
|
||||
const row = tbody.insertRow();
|
||||
row.setAttribute("data-id", id);
|
||||
|
||||
const cells = [name, surname, patronymic, experience, specialization ];
|
||||
cells.forEach((value) => {
|
||||
const cell = row.insertCell();
|
||||
cell.textContent = value;
|
||||
});
|
||||
|
||||
row.addEventListener('click', () => addAndRemoveFromList(row));
|
||||
};
|
||||
|
||||
const formatDate = (dateString) => {
|
||||
const date = new Date(dateString);
|
||||
const year = date.getFullYear();
|
||||
const month = ('0' + (date.getMonth() + 1)).slice(-2);
|
||||
const day = ('0' + date.getDate()).slice(-2);
|
||||
return `${year}-${month}-${day}`;
|
||||
};
|
||||
|
||||
const addAndRemoveFromList = (row) => {
|
||||
var id = parseInt(row.dataset.id);
|
||||
console.log(lawyers.find(x => x.id === id))
|
||||
var index = dataArray.indexOf(lawyers.find(x => x.id === id));
|
||||
if (index === -1) {
|
||||
dataArray.push(lawyers.find(x => x.id === id));
|
||||
row.classList.add("bg-info");
|
||||
row.classList.add("bg-success");
|
||||
} else {
|
||||
dataArray.splice(index, 1);
|
||||
row.classList.remove("bg-info");
|
||||
row.classList.remove("bg-success");
|
||||
}
|
||||
console.log(dataArray);
|
||||
}
|
@ -1,121 +0,0 @@
|
||||
|
||||
const dateFromInput = document.getElementById("date-from-input");
|
||||
const dateToInput = document.getElementById("date-to-input");
|
||||
const generateButton = document.getElementById("generate-button");
|
||||
const sendByMailButton = document.getElementById("send-by-mail-button");
|
||||
const dateToSpan = document.getElementById("date-to-span");
|
||||
const dateFromSpan = document.getElementById("date-from-span");
|
||||
const dateFrom = new Date(dateFromInput.value);
|
||||
const dateTo = new Date(dateToInput.value);
|
||||
const reportModel = {
|
||||
"DateFrom": dateFrom,
|
||||
"DateTo": dateTo
|
||||
};
|
||||
const tbody = document.getElementById("tbody");
|
||||
|
||||
function sendByMail() {
|
||||
$.ajax({
|
||||
url: "/home/sendbymailstatusreport",
|
||||
type: "POST",
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify(reportModel)
|
||||
}).done(() => {
|
||||
alert("Отчет успешно отправлен на вашу почту!")
|
||||
});
|
||||
}
|
||||
|
||||
generateButton.addEventListener("click", () => {
|
||||
const dateFrom = new Date(dateFromInput.value);
|
||||
const dateTo = new Date(dateToInput.value);
|
||||
const reportModel = {
|
||||
"DateFrom": dateFrom,
|
||||
"DateTo": dateTo
|
||||
};
|
||||
$.ajax({
|
||||
url: "/home/getreport",
|
||||
type: "POST",
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify(reportModel)
|
||||
}).done((data) => {
|
||||
dateFromSpan.innerHTML = reportModel["DateFrom"].toLocaleDateString();
|
||||
dateToSpan.innerHTML = reportModel["DateTo"].toLocaleDateString();
|
||||
renderTable(data);
|
||||
});
|
||||
});
|
||||
|
||||
function populateTable(data) {
|
||||
tbody.innerHTML = ""; // Clear the tbody before populating with new data
|
||||
|
||||
// Find the maximum length between dishes and alcohol drinks
|
||||
let maxLength = 0;
|
||||
data.forEach((item) => {
|
||||
maxLength = Math.max(maxLength, item.hearings, 1);
|
||||
});
|
||||
|
||||
// Loop through the data and create table rows
|
||||
data.forEach((item) => {
|
||||
const caseName = item.caseName;
|
||||
const hearings = item.hearings;
|
||||
const specialization = item.specialization;
|
||||
|
||||
for (let i = 0; i < maxLength; i++) {
|
||||
// Create a new row for each product, but without the productNameCell for additional dishes or drinks
|
||||
const row = document.createElement("tr");
|
||||
|
||||
if (i === 0) {
|
||||
// Create the productNameCell and set the rowSpan attribute
|
||||
const caseNameCell = document.createElement("td");
|
||||
caseNameCell.textContent = caseName;
|
||||
caseNameCell.rowSpan = maxLength; // Set the rowSpan to the maximum length
|
||||
row.appendChild(caseNameCell);
|
||||
}
|
||||
|
||||
if (i < hearings.length) {
|
||||
// Create cells for dishes if available
|
||||
const hearing = hearings[i];
|
||||
const hearingId = hearing.hearingId;
|
||||
const hearingDate = new Date(hearing.Date);
|
||||
|
||||
const hearingNumberCell = document.createElement("td");
|
||||
hearingNumberCell.textContent = hearingId;
|
||||
row.appendChild(hearingNumberCell);
|
||||
|
||||
const hearingDateCell = document.createElement("td");
|
||||
if (hearing.dateCreate === null) {
|
||||
hearingDateCell.textContent = ""
|
||||
|
||||
}
|
||||
else {
|
||||
hearingDateCell.textContent = formatDate(hearingDate); // Format the date
|
||||
} row.appendChild(hearingDateCell);
|
||||
} else {
|
||||
// Create empty cells for dishes if not available
|
||||
const emptyCell = document.createElement("td");
|
||||
row.appendChild(emptyCell);
|
||||
row.appendChild(emptyCell.cloneNode());
|
||||
}
|
||||
|
||||
if (i < 1) {
|
||||
// Create cells for alcohol drinks if available
|
||||
const specialization = specialization;
|
||||
const specializationId = specialization.specializationId;
|
||||
|
||||
const specializationNumberCell = document.createElement("td");
|
||||
specializationNumberCell.textContent = specializationId;
|
||||
row.appendChild(specializationNumberCell);
|
||||
|
||||
const specializationDateCell = document.createElement("td");
|
||||
console.log(drink.dateCreate === null);
|
||||
|
||||
row.appendChild(specializationDateCell);
|
||||
} else {
|
||||
// Create empty cells for alcohol drinks if not available
|
||||
const emptyCell = document.createElement("td");
|
||||
row.appendChild(emptyCell);
|
||||
row.appendChild(emptyCell.cloneNode());
|
||||
}
|
||||
|
||||
tbody.appendChild(row);
|
||||
}
|
||||
});
|
||||
}
|
@ -18,8 +18,8 @@ namespace CaseAccountingDataBaseImplement
|
||||
Host=localhost;
|
||||
Port=5432;
|
||||
Database=CaseAccountingDatabase;
|
||||
Username=postgres;
|
||||
Password=postgres");
|
||||
Username=courseuser;
|
||||
Password=courseuser");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
|
@ -110,15 +110,6 @@ namespace CaseAccountingDataBaseImplement.Implements
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else if (model.DateFrom != null && model.DateTo != null)
|
||||
{
|
||||
return context.Cases
|
||||
.Include(x => x.Specialization)
|
||||
.Include(x => x.User)
|
||||
.Where(x => x.Date >= model.DateFrom && x.Date <= model.DateTo)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new();
|
||||
@ -180,18 +171,18 @@ namespace CaseAccountingDataBaseImplement.Implements
|
||||
}
|
||||
}
|
||||
|
||||
public List<CaseViewModel> GetCaseMTM(int lawyerId)
|
||||
public List<HearingViewModel> GetCaseHearings(CaseSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new CaseAccountingDatabase();
|
||||
var lawyersId = context.CaseLawyers
|
||||
.Where(x => x.LawyerId == lawyerId)
|
||||
.Select(x => x.CaseId).ToList();
|
||||
return context.Cases
|
||||
.Include(x => x.Specialization)
|
||||
.Include(x => x.User)
|
||||
.Where(X => lawyersId.Contains(X.Id))
|
||||
var hearings = context.Hearings
|
||||
.Where(x => x.CaseId == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
return hearings;
|
||||
}
|
||||
|
||||
public List<SpecializationCasesViewModel>? GetSpecializationCases()
|
||||
@ -211,34 +202,5 @@ namespace CaseAccountingDataBaseImplement.Implements
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<HearingViewModel> GetCaseHearing(CaseSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new CaseAccountingDatabase();
|
||||
var hearing = context.Hearings.
|
||||
Where(x => x.CaseId == model.Id).
|
||||
Select(x => x.GetViewModel).
|
||||
ToList();
|
||||
return hearing;
|
||||
}
|
||||
|
||||
|
||||
public SpecializationViewModel GetCaseSpecialization(SpecializationSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new CaseAccountingDatabase();
|
||||
var specialization = context.Specializations.
|
||||
FirstOrDefault(x => x.Id == model.Id)?.
|
||||
GetViewModel;
|
||||
return specialization;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -83,15 +83,6 @@ namespace CaseAccountingDataBaseImplement.Implements
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else if (model.DateFrom != null && model.DateTo != null)
|
||||
{
|
||||
return context.Hearings
|
||||
.Include(x => x.Case)
|
||||
.Include(x => x.User)
|
||||
.Where(x => x.Date <= model.DateTo && x.Date >= model.DateFrom)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new();
|
||||
|
@ -0,0 +1,25 @@
|
||||
using CaseAccountingContracts.BindingModels;
|
||||
using CaseAccountingContracts.BusinessLogicContracts;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace CaseAccountingRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class ReportCustomerController : Controller
|
||||
{
|
||||
private readonly IReportCustomerLogic _reportCustomerLogic;
|
||||
|
||||
public ReportCustomerController(IReportCustomerLogic reportLogic)
|
||||
{
|
||||
_reportCustomerLogic = reportLogic;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public byte[] LawyerHearingList(LawyerHearingListBindingModel listModel)
|
||||
{
|
||||
byte[] file = _reportCustomerLogic.SaveListFile(listModel);
|
||||
return file;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
using CaseAccountingContracts.BindingModels;
|
||||
using CaseAccountingContracts.BusinessLogicContracts;
|
||||
using CaseAccountingContracts.ViewModels;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace CaseAccountingRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class ReportCustomerController : Controller
|
||||
{
|
||||
private readonly IReportCustomerLogic reportLogic;
|
||||
|
||||
public ReportCustomerController(IReportCustomerLogic reportLogic)
|
||||
{
|
||||
this.reportLogic = reportLogic;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public byte[] LawyerHearinglist(LawyerHearingListBindingModel listModel)
|
||||
{
|
||||
byte[] file = reportLogic.SaveListFile(listModel);
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public List<ReportHearingSpecializationViewModel> GetReportData(ReportBindingModel reportModel)
|
||||
{
|
||||
var list = reportLogic.GetHearingSpecialization(reportModel);
|
||||
return list;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void SendByMailStatusReport(ReportBindingModel reportModel)
|
||||
{
|
||||
reportLogic.SendByMailStatusReport(reportModel);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
using CaseAccountingBusinessLogic.BusinessLogic.OfficePackage;
|
||||
using CaseAccountingBusinessLogic.BusinessLogics;
|
||||
using CaseAccountingBusinessLogic.OfficePackage;
|
||||
using CaseAccountingBusinessLogic.OfficePackage.HelperModels;
|
||||
using CaseAccountingContracts.BindingModels;
|
||||
using CaseAccountingContracts.BusinessLogicContracts;
|
||||
using CaseAccountingContracts.StoragesContracts;
|
||||
@ -31,11 +30,6 @@ builder.Services.AddTransient<ISpecializationLogic, SpecializationLogic>();
|
||||
builder.Services.AddTransient<IUserLogic, UserLogic>();
|
||||
|
||||
builder.Services.AddTransient<IReportProviderLogic, ReportProviderLogic>();
|
||||
builder.Services.AddTransient<IReportCustomerLogic, ReportCustomerLogic>();
|
||||
|
||||
builder.Services.AddTransient<WordBuilderCustomer>();
|
||||
builder.Services.AddTransient<ExcelBuilderCustomer>();
|
||||
builder.Services.AddTransient<PdfBuilderCustomer>();
|
||||
|
||||
builder.Services.AddTransient<WordBuilderProvider>();
|
||||
builder.Services.AddTransient<ExcelBuilderProvider>();
|
||||
|
Loading…
x
Reference in New Issue
Block a user