Отчёт
This commit is contained in:
parent
de03e5b141
commit
acaa63c004
@ -5,6 +5,7 @@ using HotelContracts.BusinessLogicsContracts;
|
|||||||
using HotelContracts.SearchModels;
|
using HotelContracts.SearchModels;
|
||||||
using HotelContracts.StoragesContracts;
|
using HotelContracts.StoragesContracts;
|
||||||
using HotelContracts.ViewModels;
|
using HotelContracts.ViewModels;
|
||||||
|
using HotelDataBaseImplement.Models;
|
||||||
|
|
||||||
namespace HotelBusinessLogic.BusinessLogics
|
namespace HotelBusinessLogic.BusinessLogics
|
||||||
{
|
{
|
||||||
@ -14,16 +15,18 @@ namespace HotelBusinessLogic.BusinessLogics
|
|||||||
private readonly ILunchStorage _lunchStorage;
|
private readonly ILunchStorage _lunchStorage;
|
||||||
private readonly IMealPlanStorage _mealPlanStorage;
|
private readonly IMealPlanStorage _mealPlanStorage;
|
||||||
private readonly IConferenceBookingStorage _conferenceBookingStorage;
|
private readonly IConferenceBookingStorage _conferenceBookingStorage;
|
||||||
|
private readonly IConferenceStorage _conferenceStorage;
|
||||||
private readonly AbstractSaveToExcelHeadwaiter _saveToExcel;
|
private readonly AbstractSaveToExcelHeadwaiter _saveToExcel;
|
||||||
private readonly AbstractSaveToWordHeadwaitre _saveToWord;
|
private readonly AbstractSaveToWordHeadwaitre _saveToWord;
|
||||||
private readonly AbstractSaveToPdfHeadwaiter _saveToPdf;
|
private readonly AbstractSaveToPdfHeadwaiter _saveToPdf;
|
||||||
|
|
||||||
public ReportLogicHeadwaiter(IRoomStorage roomStorage, ILunchStorage lunchStorage, IMealPlanStorage mealPlanStorage, IConferenceBookingStorage conferenceBookingStorage, AbstractSaveToExcelHeadwaiter saveToExcel, AbstractSaveToWordHeadwaitre saveToWord, AbstractSaveToPdfHeadwaiter saveToPdf)
|
public ReportLogicHeadwaiter(IRoomStorage roomStorage, ILunchStorage lunchStorage, IMealPlanStorage mealPlanStorage, IConferenceBookingStorage conferenceBookingStorage, IConferenceStorage conferenceStorage, AbstractSaveToExcelHeadwaiter saveToExcel, AbstractSaveToWordHeadwaitre saveToWord, AbstractSaveToPdfHeadwaiter saveToPdf)
|
||||||
{
|
{
|
||||||
_roomStorage = roomStorage;
|
_roomStorage = roomStorage;
|
||||||
_lunchStorage = lunchStorage;
|
_lunchStorage = lunchStorage;
|
||||||
_mealPlanStorage = mealPlanStorage;
|
_mealPlanStorage = mealPlanStorage;
|
||||||
_conferenceBookingStorage = conferenceBookingStorage;
|
_conferenceBookingStorage = conferenceBookingStorage;
|
||||||
|
_conferenceStorage = conferenceStorage;
|
||||||
_saveToExcel = saveToExcel;
|
_saveToExcel = saveToExcel;
|
||||||
_saveToWord = saveToWord;
|
_saveToWord = saveToWord;
|
||||||
_saveToPdf = saveToPdf;
|
_saveToPdf = saveToPdf;
|
||||||
@ -106,17 +109,20 @@ namespace HotelBusinessLogic.BusinessLogics
|
|||||||
DateTo = model.DateTo
|
DateTo = model.DateTo
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var conferenced = _conferenceStorage.GetFullList();
|
||||||
|
|
||||||
foreach (var conferenceBooking in listConferenceBookings)
|
foreach (var conferenceBooking in listConferenceBookings)
|
||||||
{
|
{
|
||||||
foreach (var mp in conferenceBooking.ConferenceBookingLunches.Values)
|
foreach (var mp in conferenceBooking.ConferenceBookingLunches.Values)
|
||||||
{
|
{
|
||||||
|
var conferenceId = conferenceBooking.ConferenceId;
|
||||||
|
var conference = conferenced.FirstOrDefault(dp => dp.Id == conferenceId);
|
||||||
listAll.Add(new ReportLunchesViewModel
|
listAll.Add(new ReportLunchesViewModel
|
||||||
{
|
{
|
||||||
LunchName = mp.LunchName,
|
LunchName = mp.LunchName,
|
||||||
LunchPrice = mp.LunchPrice,
|
LunchPrice = mp.LunchPrice,
|
||||||
NameHall = conferenceBooking.NameHall,
|
ConferenceName = conference.ConferenceName,
|
||||||
BookingDate = conferenceBooking.BookingDate
|
StartDate = conference.StartDate
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ namespace HotelBusinessLogic.OfficePackage
|
|||||||
CreateTable(new List<string> { "3cm", "3cm", "3cm", "4cm", "4cm" });
|
CreateTable(new List<string> { "3cm", "3cm", "3cm", "4cm", "4cm" });
|
||||||
CreateRow(new PdfRowParameters
|
CreateRow(new PdfRowParameters
|
||||||
{
|
{
|
||||||
Texts = new List<string> { "Обед", "Комната", "Цена комнаты", "Бронирование", "Дата брони" },
|
Texts = new List<string> { "Обед", "Комната", "Цена комнаты", "Конференцияя", "Дата" },
|
||||||
Style = "NormalTitle",
|
Style = "NormalTitle",
|
||||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||||
});
|
});
|
||||||
@ -37,7 +37,7 @@ namespace HotelBusinessLogic.OfficePackage
|
|||||||
}
|
}
|
||||||
CreateRow(new PdfRowParameters
|
CreateRow(new PdfRowParameters
|
||||||
{
|
{
|
||||||
Texts = new List<string> { lunch.LunchName.ToString(), lunch.RoomName, IsCost is true ? lunch.RoomPrice.ToString() : string.Empty, lunch.NameHall, lunch.BookingDate?.ToShortDateString() ?? string.Empty },
|
Texts = new List<string> { lunch.LunchName.ToString(), lunch.RoomName, IsCost is true ? lunch.RoomPrice.ToString() : string.Empty, lunch.ConferenceName, lunch.StartDate?.ToShortDateString() ?? string.Empty },
|
||||||
Style = "Normal",
|
Style = "Normal",
|
||||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||||
});
|
});
|
||||||
|
@ -4,11 +4,10 @@
|
|||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public string RoomName { get; set; } = string.Empty;
|
public string RoomName { get; set; } = string.Empty;
|
||||||
public string NameHall { get; set; } = string.Empty;
|
public double RoomPrice { get; set; }
|
||||||
public DateTime? BookingDate { get; set; }
|
public string ConferenceName { get; set; } = string.Empty;
|
||||||
|
public DateTime? StartDate { get; set; }
|
||||||
public string LunchName { get; set; } = string.Empty;
|
public string LunchName { get; set; } = string.Empty;
|
||||||
public double LunchPrice { get; set; }
|
public double LunchPrice { get; set; }
|
||||||
public double RoomPrice { get; set; }
|
|
||||||
public string RoomFrame { get; set; } = string.Empty;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||||
using HostrelHeadwaiterApp;
|
using HostrelHeadwaiterApp;
|
||||||
using HotelContracts.BindingModels;
|
using HotelContracts.BindingModels;
|
||||||
|
using HotelContracts.BusinessLogicsContracts;
|
||||||
using HotelContracts.SearchModels;
|
using HotelContracts.SearchModels;
|
||||||
using HotelContracts.ViewModels;
|
using HotelContracts.ViewModels;
|
||||||
using HotelDataBaseImplement.Models;
|
using HotelDataBaseImplement.Models;
|
||||||
@ -16,10 +17,12 @@ namespace HotelHeadwaiterApp.Controllers
|
|||||||
public class HomeController : Controller
|
public class HomeController : Controller
|
||||||
{
|
{
|
||||||
private readonly ILogger<HomeController> _logger;
|
private readonly ILogger<HomeController> _logger;
|
||||||
|
private readonly IReportHeadwaiterLogic _report;
|
||||||
|
|
||||||
public HomeController(ILogger<HomeController> logger)
|
public HomeController(ILogger<HomeController> logger, IReportHeadwaiterLogic report)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
_report = report;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult Index()
|
public IActionResult Index()
|
||||||
@ -608,7 +611,100 @@ namespace HotelHeadwaiterApp.Controllers
|
|||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult GetExcelFile()
|
public IActionResult GetExcelFile()
|
||||||
{
|
{
|
||||||
return new PhysicalFileResult("C:\\ReportsCourseWork\\excelfile.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
return new PhysicalFileResult("C:\\Reports\\excelfile.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||||
|
}
|
||||||
|
|
||||||
|
public IActionResult GetPdfFile()
|
||||||
|
{
|
||||||
|
return new PhysicalFileResult("C:\\ReportsCourseWork\\pdffile.pdf", "application/pdf");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult ListLunchesToPdfFile()
|
||||||
|
{
|
||||||
|
if (APIClient.Headwaiter == null)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
return View("ListLunchesToPdfFile");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void ListLunchesToPdfFile(DateTime dateFrom, DateTime dateTo)
|
||||||
|
{
|
||||||
|
if (APIClient.Headwaiter == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||||
|
}
|
||||||
|
APIClient.PostRequest("api/report/CreateHeadwaiterReportToPdfFile", new ReportHeadwaiterBindingModel
|
||||||
|
{
|
||||||
|
DateFrom = dateFrom,
|
||||||
|
DateTo = dateTo,
|
||||||
|
HeadwaiterId = APIClient.Headwaiter.Id
|
||||||
|
});
|
||||||
|
Response.Redirect("ListLunchesToPdfFile");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public string GetLunchesReport(DateTime dateFrom, DateTime dateTo)
|
||||||
|
{
|
||||||
|
if (APIClient.Headwaiter == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||||
|
}
|
||||||
|
List<ReportLunchesViewModel> result;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
result = _report.GetLunches(new ReportHeadwaiterBindingModel
|
||||||
|
{
|
||||||
|
HeadwaiterId = APIClient.Headwaiter.Id,
|
||||||
|
DateFrom = dateFrom,
|
||||||
|
DateTo = dateTo
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка создания отчета");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
double sum = 0;
|
||||||
|
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 += "<th scope=\"col\">Дата</th>";
|
||||||
|
table += "</tr>";
|
||||||
|
table += "</thead>";
|
||||||
|
foreach (var report in result)
|
||||||
|
{
|
||||||
|
bool IsCost = true;
|
||||||
|
if (report.RoomPrice == 0)
|
||||||
|
{
|
||||||
|
IsCost = false;
|
||||||
|
}
|
||||||
|
table += "<tbody>";
|
||||||
|
table += "<tr>";
|
||||||
|
table += $"<td>{report.LunchName}</td>";
|
||||||
|
table += $"<td>{report.RoomName}</td>";
|
||||||
|
table += $"<td>{(IsCost ? report.RoomPrice.ToString() : string.Empty)}</td>";
|
||||||
|
table += $"<td>{report.ConferenceName}</td>";
|
||||||
|
table += $"<td>{report.StartDate?.ToShortDateString()}</td>";
|
||||||
|
table += "</tr>";
|
||||||
|
table += "</tbody>";
|
||||||
|
sum += report.RoomPrice;
|
||||||
|
}
|
||||||
|
table += "<tfoot class=\"table-secondary\">";
|
||||||
|
table += $"<tr><th colspan=\"2\">Итого:</th><th>{sum}</th><th colspan=\"2\"></th></tr>";
|
||||||
|
table += "</tfoot>";
|
||||||
|
table += "</table>";
|
||||||
|
table += "</div>";
|
||||||
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ builder.Services.AddTransient<IReportHeadwaiterLogic, ReportLogicHeadwaiter>();
|
|||||||
builder.Services.AddTransient<ILunchStorage, LunchStorage>();
|
builder.Services.AddTransient<ILunchStorage, LunchStorage>();
|
||||||
builder.Services.AddTransient<IMealPlanStorage, MealPlanStorage>();
|
builder.Services.AddTransient<IMealPlanStorage, MealPlanStorage>();
|
||||||
builder.Services.AddTransient<IConferenceBookingStorage, ConferenceBookingStorage>();
|
builder.Services.AddTransient<IConferenceBookingStorage, ConferenceBookingStorage>();
|
||||||
|
builder.Services.AddTransient<IConferenceStorage, ConferenceStorage>();
|
||||||
builder.Services.AddTransient<IRoomStorage, RoomStorage>();
|
builder.Services.AddTransient<IRoomStorage, RoomStorage>();
|
||||||
builder.Services.AddTransient<AbstractSaveToExcelHeadwaiter, SaveToExcelHeadwaiter>();
|
builder.Services.AddTransient<AbstractSaveToExcelHeadwaiter, SaveToExcelHeadwaiter>();
|
||||||
builder.Services.AddTransient<AbstractSaveToPdfHeadwaiter, SaveToPdfHeadwaiter>();
|
builder.Services.AddTransient<AbstractSaveToPdfHeadwaiter, SaveToPdfHeadwaiter>();
|
||||||
|
@ -0,0 +1,60 @@
|
|||||||
|
@using HotelContracts.ViewModels
|
||||||
|
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "ListLunchesToPdfFile";
|
||||||
|
}
|
||||||
|
|
||||||
|
<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="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/GetLunchesReport",
|
||||||
|
data: { dateFrom: dateFrom, dateTo: dateTo },
|
||||||
|
success: function (result) {
|
||||||
|
if (result != null) {
|
||||||
|
$('#report').html(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
check();
|
||||||
|
$('#demonstrate').on('click', (e) => check());
|
||||||
|
</script>
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user