Report views.
This commit is contained in:
parent
f777a0ee3c
commit
df16e3dba4
ComputerStoreEmployeeApp
Controllers
Views
75
ComputerStoreEmployeeApp/Controllers/ReportController.cs
Normal file
75
ComputerStoreEmployeeApp/Controllers/ReportController.cs
Normal file
@ -0,0 +1,75 @@
|
||||
using ComputerStoreContracts.ViewModels;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ComputerStoreEmployeeApp.Controllers
|
||||
{
|
||||
public class ReportController : Controller
|
||||
{
|
||||
private readonly ILogger<ReportController> _logger;
|
||||
|
||||
public ReportController(ILogger<ReportController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public IActionResult ReportMenu()
|
||||
{
|
||||
APIClient.productComponents = new();
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult ConsignmentsReport()
|
||||
{
|
||||
ViewBag.Components = APIClient.GetRequest<List<ComponentViewModel>>("api/main/getcomponentslist").Result;
|
||||
|
||||
return View(APIClient.productComponents);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult SaveExcel(List<ReportConsignmentsViewModel> consignments)
|
||||
{
|
||||
|
||||
|
||||
return View("ReportMenu");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult SaveWord(List<ReportConsignmentsViewModel> consignments)
|
||||
{
|
||||
|
||||
|
||||
return View("ReportMenu");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void ConsignmentComponents(int id, int componentquantity)
|
||||
{
|
||||
var component = APIClient.GetRequest<ComponentViewModel>($"api/main/getcomponent?id={id}").Result;
|
||||
if (APIClient.productComponents.ContainsKey(component.ID))
|
||||
{
|
||||
if(componentquantity == 0)
|
||||
{
|
||||
APIClient.productComponents.Remove(component.ID);
|
||||
}
|
||||
else
|
||||
{
|
||||
APIClient.productComponents[component.ID] = (component, componentquantity);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
APIClient.productComponents.Add(component.ID, (component, componentquantity));
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult ConsignmentsReportResult()
|
||||
{
|
||||
ViewBag.Consignments = APIClient.GetRequest<List<ReportConsignmentsViewModel>>($"api/main/getreportconsignmentslist").Result;
|
||||
return View("ConsignmentsReport", APIClient.productComponents);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,18 +0,0 @@
|
||||
@{
|
||||
ViewData["Title"] = "Choose a request";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Choose a request</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="flex-container" style="flex-direction: row; justify-content: space-between; display: flex; height: 100vh;">
|
||||
<div class="flex-containerB1" style="flex-direction: column; flex: 4; gap: 20px; display: flex; align-items: center; justify-content: center;">
|
||||
<select id="product" name="product" class="form-control" asp-items="@(new SelectList(@ViewBag.PCs,"ID","Name"))"></select>
|
||||
<input type="submit" id="productbtn" value="DELETE" class="btn btn-primary" />
|
||||
</div>
|
||||
</div>
|
||||
@if (!string.IsNullOrEmpty(ViewBag.Message))
|
||||
{
|
||||
<script>alert("@ViewBag.Message");</script>
|
||||
}
|
||||
</form>
|
130
ComputerStoreEmployeeApp/Views/Report/ConsignmentsReport.cshtml
Normal file
130
ComputerStoreEmployeeApp/Views/Report/ConsignmentsReport.cshtml
Normal file
@ -0,0 +1,130 @@
|
||||
@using ComputerStoreDataModels.Models;
|
||||
@using ComputerStoreContracts.ViewModels;
|
||||
@model Dictionary<int, (IComponentModel, int)>
|
||||
@{
|
||||
ViewData["Title"] = "Find consignment by components";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Enter components</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
@if(ViewBag.Components != null)
|
||||
{
|
||||
<div class="flex-container" style="flex-direction: row; justify-content: space-between; display: flex; height: 100vh;">
|
||||
<div class="flex-containerB1" style="flex-direction: column; flex: 4; gap: 20px; display: flex; align-items: center; justify-content: center;">
|
||||
<h1>Component:</h1>
|
||||
<select id="component" name="component" class="form-control" asp-items="@(new SelectList(@ViewBag.Components,"ID","Name"))"></select>
|
||||
<div class="componentquantity" style="text-align: left; font-size: 15px;">Quantity:</div>
|
||||
<input type="text" id="componentquantity" name="componentquantity" />
|
||||
<input type="button" id="componentbtn" value="ADD" class="btn btn-primary" />
|
||||
</div>
|
||||
<div class="flex-containerB2" style="flex-direction: column; flex: 4; gap: 20px; display: flex; align-items: center; justify-content: center;">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th>
|
||||
Name
|
||||
</th>
|
||||
<th>
|
||||
Count
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Value.Item1.Name)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Value.Item2)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<input type="button" id="findbtn" value="FIND" class="btn btn-primary" />
|
||||
</div>
|
||||
}
|
||||
|
||||
@if(ViewBag.Consignments != null)
|
||||
{
|
||||
<div class="flex-containerC1" style="flex-direction: row; flex: 4; gap: 20px; display: flex; align-items: center; justify-content: center;">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
<th>
|
||||
ConsignmentID
|
||||
</th>
|
||||
<th>
|
||||
Products
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (ReportConsignmentsViewModel item in ViewBag.Consignments)
|
||||
{
|
||||
<tr>
|
||||
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.ID)
|
||||
</td>
|
||||
<td>
|
||||
<table>
|
||||
@foreach (var product in item.Products)
|
||||
{
|
||||
<tr>
|
||||
<td>@product.product</td>
|
||||
<td>@product.count</td>
|
||||
</tr>
|
||||
|
||||
}
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="flex-containerB2" style="flex-direction: column; flex: 4; gap: 20px; display: flex; align-items: center; justify-content: center;">
|
||||
<form method="post" asp-controller="Report" asp-action="SaveExcel" asp-route-consignments="@ViewBag.Consignments">
|
||||
<input type="submit" id="consignmentreport" value="Save excel" class="btn btn-primary" style="font-size: 20pt; width: auto;" />
|
||||
</form>
|
||||
<form method="post" asp-controller="Report" asp-action="SaveWord" asp-route-consignments="@ViewBag.Consignments">
|
||||
<input type="submit" id="consignmentreport" value="Save word" class="btn btn-primary" style="font-size: 20pt; width: auto;" />
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<input type="submit" id="findbtn" value="FIND" class="btn btn-primary" />
|
||||
</div>
|
||||
}
|
||||
@if (!string.IsNullOrEmpty(ViewBag.Message))
|
||||
{
|
||||
<script>alert("@ViewBag.Message");</script>
|
||||
}
|
||||
</form>
|
||||
<script>
|
||||
$('#componentbtn').on("click", function () {
|
||||
var count = $('#componentquantity').val();
|
||||
var id = $('#component').val();
|
||||
|
||||
$.when(ajax1(id, count)).done(function (a1) {
|
||||
window.location.href = '/Report/ConsignmentsReport'
|
||||
})
|
||||
});
|
||||
|
||||
function ajax1(id, count) {
|
||||
|
||||
return $.ajax({
|
||||
method: "POST",
|
||||
url: "/Report/ConsignmentComponents",
|
||||
data: { id: id, componentquantity: count }
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
</script>
|
20
ComputerStoreEmployeeApp/Views/Report/ReportMenu.cshtml
Normal file
20
ComputerStoreEmployeeApp/Views/Report/ReportMenu.cshtml
Normal file
@ -0,0 +1,20 @@
|
||||
@{
|
||||
ViewData["Title"] = "Reports";
|
||||
}
|
||||
<div class="text-center">
|
||||
<div class="flex-container" style="flex-direction: row; justify-content: center; display: flex; height: 100vh;">
|
||||
<div class="flex-containerA1" style="flex-direction: column; align-items: center; display: flex; gap: 35px">
|
||||
<h1>Which kind of report do you want to receive?</h1>
|
||||
<div class="flex-containerB1" style="display: flex; align-items: center; margin-top: 120px;">
|
||||
<form method="get" asp-controller="Report" asp-action="ConsignmentsReport">
|
||||
<input type="submit" id="consreport" value="Consignments report by components" class="btn btn-primary" style="font-size: 20pt; width: auto;" />
|
||||
</form>
|
||||
</div>
|
||||
<div class="flex-containerB2" style="display: flex; align-items: center;">
|
||||
<form method="get" asp-controller="Report" asp-action="PCsProductsReport">
|
||||
<input type="submit" id="datereport" value="PCs and Products by date" class="btn btn-primary" style="font-size: 20pt; width: auto;" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -34,12 +34,9 @@
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="PCMenu">PCs</a>
|
||||
</li>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Request">Requests</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Report">Reports</a>
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Report" asp-action="ReportMenu">Reports</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user