Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create dispatcher page for dispatchers #71

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,39 @@ public async Task<IActionResult> Index(int? pagenumber)
ViewBag.DispatcherReviews = dispatcherReviewResponse;
return View();
}
public async Task<IActionResult> PersonalIndex(int? pagenumber)
{
var response = await _dispatcherReviewDataStore.GetDispatcherReviews(pagenumber);


if (response is null)
{
return BadRequest();
}
ViewBag.PageSize = response.PageSize;
ViewBag.PageCount = response.TotalPages;
ViewBag.TotalCount = response.TotalCount;
ViewBag.CurrentPage = response.PageNumber;
ViewBag.HasPreviousPage = response.HasPreviousPage;
ViewBag.HasNextPage = response.HasNextPage;

var dispatcherReviewResponse = response.Data.Select(r => new
{
r.Id,
FuelSpended = r.FuelSpended.ToString("0.00").PadLeft(4, '0'),
r.DistanceCovered,
r.Date,
r.CarMeduimFuelConsumption,
r.CarName,
r.DispatcherName,
r.MechanicName,
r.OperatorName,
r.DriverName
}).ToList();

ViewBag.DispatcherReviews = dispatcherReviewResponse;
return View();
}

public async Task<IActionResult> Details(int id)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
@model CheckDrive.ApiContracts.DispatcherReview.DispatcherReviewDto

@{
ViewData["Title"] = "Dispatcher Reviews (Personal)";
Layout = "~/Views/Shared/_PersonalLayout.cshtml";
}

<div class="container mt-5">
<div class="row justify-content-center">
<div class="col-md-10">
<div class="table-responsive">
<table class="table table-bordered table-striped table-hover shadow">
<thead>
<tr>
<th scope="col" style="width: 13%">Haydovchi F.I</th>
<th scope="col" style="width: 10%">Marka</th>
<th scope="col" style="width: 10%">Mexanik F.I</th>
<th scope="col" style="width: 10%">Chiqish</th>
<th scope="col" style="width: 10%">Kirish</th>
<th scope="col" style="width: 10%">Operator F.I</th>
<th scope="col" style="width: 13%">O'rtacha Yoqilg'i</th>
<th scope="col" style="width: 5%">Sarf</th>
<th scope="col" style="width: 15%">Bosib O'tilgan M</th>
</tr>
</thead>
<tbody>
@foreach (var item in ViewBag.DispatcherReviews)
{
<tr>
<td>@item.DriverName</td>
<td>@item.CarName</td>
<td>@item.MechanicName</td>
<td>@item.MechanicName</td>
<td>@item.MechanicName</td>
<td>@item.OperatorName</td>
<td>@item.FuelSpended</td>
<td>@item.DistanceCovered</td>
</tr>
}
</tbody>
</table>
</div>

<div class="col-md-12">
<div class="d-flex justify-content-end align-items-center my-3">
<nav aria-label="Page navigation">
<ul class="pagination mb-0">
@if (ViewBag.HasPreviousPage)
{
<li class="page-item">
<a class="page-link" href="@Url.Action("PersonalIndex", new { pageNumber = 1 })" aria-label="First">
<span aria-hidden="true">&laquo;</span>
</a>
</li>
<li class="page-item">
<a class="page-link" href="@Url.Action("PersonalIndex", new { pageNumber = ViewBag.CurrentPage - 1 })">@(@ViewBag.CurrentPage - 1)</a>
</li>
}

<li class="page-item active">
<span class="page-link">@ViewBag.CurrentPage</span>
</li>

@if (ViewBag.CurrentPage < ViewBag.PageCount)
{
<li class="page-item">
<a class="page-link" href="@Url.Action("PersonalIndex", new { pageNumber = ViewBag.CurrentPage + 1 })">@(@ViewBag.CurrentPage + 1)</a>
</li>
}
@if (ViewBag.CurrentPage + 1 < ViewBag.PageCount)
{
<li class="page-item">
<a class="page-link" href="@Url.Action("PersonalIndex", new { pageNumber = ViewBag.CurrentPage + 2 })">@(@ViewBag.CurrentPage + 2)</a>
</li>
}
@if (ViewBag.CurrentPage + 2 < ViewBag.PageCount)
{
<li class="page-item">
<a class="page-link" href="@Url.Action("PersonalIndex", new { pageNumber = ViewBag.PageCount })" aria-label="Last">
<span aria-hidden="true">&raquo;</span>
</a>
</li>
}
</ul>
</nav>
<div class="p-2">
<p class="h6 mb-0">@ViewBag.CurrentPage of @ViewBag.PageCount pages (@ViewBag.TotalCount items)</p>
</div>
</div>
</div>
</div>
</div>
</div>

<style>
.badge {
font-size: 0.8rem;
padding: 5px 10px;
border-radius: 5px;
}

.bg-success {
background-color: #28a745;
}

.bg-danger {
background-color: #dc3545;
}

.bg-secondary {
background-color: #6c757d;
}

.container {
margin-top: 30px;
}

.table-bordered {
border: 1px solid #dee2e6;
}

.table-bordered th,
.table-bordered td {
border: 1px solid #dee2e6;
}

.pagination {
justify-content: flex-end;
}

.shadow {
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.pagination .page-link {
margin-left: 5px;
}

.pagination .page-item.shadow {
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
</style>
6 changes: 6 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Views/Shared/_SideBar.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@
text = "Mexanik(Topshiruvchi) oynasi",
iconCss = "fa-solid fa-person-chalkboard",
url = Url.Action("PersonalIndex", "MechanicHandovers")
});
menuItems.Add(new
{
text = "Dispatcher oynasi",
iconCss = "fa-solid fa-person-chalkboard",
url = Url.Action("PersonalIndex", "DispatcherReviews")
});
}

Expand Down
Loading