diff --git a/CheckDrive.Web/CheckDrive.Web/Controllers/DispatcherReviewsController.cs b/CheckDrive.Web/CheckDrive.Web/Controllers/DispatcherReviewsController.cs index a8d90484..5b4c90ae 100644 --- a/CheckDrive.Web/CheckDrive.Web/Controllers/DispatcherReviewsController.cs +++ b/CheckDrive.Web/CheckDrive.Web/Controllers/DispatcherReviewsController.cs @@ -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) { diff --git a/CheckDrive.Web/CheckDrive.Web/Views/DispatcherReviews/PersonalIndex.cshtml b/CheckDrive.Web/CheckDrive.Web/Views/DispatcherReviews/PersonalIndex.cshtml new file mode 100644 index 00000000..5be7d14d --- /dev/null +++ b/CheckDrive.Web/CheckDrive.Web/Views/DispatcherReviews/PersonalIndex.cshtml @@ -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">«</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">»</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> diff --git a/CheckDrive.Web/CheckDrive.Web/Views/Shared/_SideBar.cshtml b/CheckDrive.Web/CheckDrive.Web/Views/Shared/_SideBar.cshtml index ab4ac120..858fe73d 100644 --- a/CheckDrive.Web/CheckDrive.Web/Views/Shared/_SideBar.cshtml +++ b/CheckDrive.Web/CheckDrive.Web/Views/Shared/_SideBar.cshtml @@ -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") }); }