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

update dispatcher review page #244

Merged
merged 3 commits into from
Dec 8, 2024
Merged
Changes from 2 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
88 changes: 23 additions & 65 deletions CheckDrive.Web/CheckDrive.Web/Views/DispatcherReviews/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
}

<form asp-controller="DispatcherReviews" asp-action="Index">
<div class="row">
<div class="row mt-4">
<div class="d-flex justify-content-between">
<!-- Search -->
<div class="col-md-4 mb-4">
<div class="col-md-4 mb-4 filter-bar">
<div class="input-group">
<input type="text" class="form-control rounded-left" placeholder="ishchilarni izlash..." name="searchString" value="@ViewBag.SearchString">
<div class="input-group-append">
Expand All @@ -21,7 +21,7 @@
</div>
<div class="col-md-4 mb-4 d-flex align-items-center">
<input type="date" name="date" class="form-control me-2">
<div class="dropdown">
<div class="create-btn">
<button class="btn btn-outline-info dropdown-toggle" type="button" id="dropdownMenuButton" data-bs-toggle="dropdown" aria-expanded="false">
<i class="fa-solid fa-download"></i> Yuklab olish
</button>
Expand All @@ -37,104 +37,62 @@

<div class="row">
<div class="col-12">
<ejs-grid id="dispatcherReview-list" dataSource="@ViewBag.DispatcherReviews" gridLines="Vertical" allowSorting="true" dataBound="onDataBound">
<ejs-grid
id="dispatcherReview-list"
dataSource="@ViewBag.DispatcherReviews"
gridLines="Both"
allowSorting="true"
allowPaging="true"
dataBound="onDataBound">
<e-grid-pagesettings pageSize="10"></e-grid-pagesettings>
<e-grid-columns>
<e-grid-column headerText="Haydovchi F.I.SH" field="DriverName" type="string" textAlign=Center headerTextAlign=Center width="200"></e-grid-column>
<e-grid-column headerText="Marka" field="CarName" type="string" textAlign=Center headerTextAlign=Center width="200"></e-grid-column>
<e-grid-column headerText="Haydovchi F.I.SH" field="DriverName" type="string" textAlign=Center headerTextAlign=Center ></e-grid-column>
<e-grid-column headerText="Marka" field="CarName" type="string" textAlign=Center headerTextAlign=Center ></e-grid-column>
<e-grid-column headerText="Dispetcher F.I.SH" field="DispatcherName" type="string" textAlign=Center headerTextAlign=Center></e-grid-column>
<e-grid-column headerText="Mexanik F.I.SH" field="MechanicName" type="string" textAlign=Center headerTextAlign=Center width="200"></e-grid-column>
<e-grid-column headerText="Operator F.I.SH" field="OperatorName" type="string" textAlign=Center headerTextAlign=Center width="200"></e-grid-column>
<e-grid-column headerText="Mexanik F.I.SH" field="MechanicName" type="string" textAlign=Center headerTextAlign=Center ></e-grid-column>
<e-grid-column headerText="Operator F.I.SH" field="OperatorName" type="string" textAlign=Center headerTextAlign=Center></e-grid-column>
<e-grid-column headerText="Ro'yxatga olingan vaqt" field="Date" type="date" format="dd-MM-yyyy | HH:mm" textAlign=Center headerTextAlign=Center></e-grid-column>
<e-grid-column width="100" type="text" textAlign="Center" template="#actionTemplate"></e-grid-column>
<e-grid-column type="text" textAlign="Center" template="#actionTemplate"></e-grid-column>
</e-grid-columns>
</ejs-grid>
</div>
</div>

<div class="d-flex justify-content-between align-items-center my-3">
<nav aria-label="Page navigation">
<ul class="pagination">
@if (ViewBag.HasPreviousPage)
{
<li class="page-item">
<a class="page-link" href="@Url.Action("Index", 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("Index", new { pageNumber = ViewBag.CurrentPage - 1 })">@(@ViewBag.CurrentPage - 1)</a>
</li>
}
@if (ViewBag.HasNextPage)
{
<li class="page-item active">
<span class="page-link">@ViewBag.CurrentPage</span>
</li>
<li class="page-item">
<a class="page-link" href="@Url.Action("Index", new { pageNumber = ViewBag.CurrentPage + 1 })">@(@ViewBag.CurrentPage + 1)</a>
</li>
<li class="page-item">
<a class="page-link" href="@Url.Action("Index", 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.PageCount sahifadan @ViewBag.CurrentPage tasi ( umumiy dispetcherlar amallari soni: @ViewBag.TotalCount)</p>
</div>
</div>
<script id="templat" type="text/x-templat">
<div>
<a rel='nofollow' href="DispatcherReviews/Details/${Id}">${Id}</a>
</div>
</script>
<script>
// Default selected year and month
let selectedYear = new Date().getFullYear(); // Current year
let selectedMonth = new Date().getMonth() + 1; // Current month (months are zero-based)
let selectedYear = new Date().getFullYear();
let selectedMonth = new Date().getMonth() + 1;

// Function to handle the change event in the calendar
function valueChange(args) {
var selectedDate = args.value;
selectedYear = selectedDate.getFullYear();
selectedMonth = selectedDate.getMonth() + 1; // Months are zero-based
selectedMonth = selectedDate.getMonth() + 1;

// Optionally, update a label to display the selected date (if you have one)
document.getElementById('date_label').textContent = 'Выбранное значение: ' + selectedDate.toDateString();
}

// Prevent the dropdown from closing when clicking inside
document.getElementById('dropdownMenu').addEventListener('click', function (event) {
event.stopPropagation(); // Stops the dropdown from closing when interacting with its contents
event.stopPropagation();
});

// Handle the download button click
document.getElementById('downloadButton').addEventListener('click', function (e) {
e.preventDefault(); // Prevent the default action of the link
e.preventDefault();

// Construct the download URL using the selected year and month
const url = `/DispatcherReviews/Download?year=${selectedYear}&month=${selectedMonth}`;

// Create a temporary link to trigger the download
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', ''); // Add download attribute to force download
link.setAttribute('download', '');
document.body.appendChild(link);
link.click();
document.body.removeChild(link); // Clean up
document.body.removeChild(link);

// Manually close the dropdown after downloading
const dropdown = bootstrap.Dropdown.getInstance(document.getElementById('dropdownMenuButton'));
dropdown.hide();
});

function onDataBound() {
// Получаем все элементы заголовков колонок
const headers = document.querySelectorAll('#dispatcherReview-list .e-headercell');

// Добавляем title атрибут к каждому элементу заголовка
headers.forEach(header => {
header.setAttribute('title', header.innerText.trim());
});
Expand Down