π TimesheetList.cshtml Documentation
Path:
IrbyImaging/Views/FieldLog/TimesheetList.cshtml
Purpose: Render and filter submitted timesheets in a dynamic, user-friendly table.
π Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- File Structure & Location
- Key Functional Areas
4.1 Filter Section
4.2 Timesheet Table
4.3 AJAX Filter Functionality
4.4 Styles & Theming - Data Models & ViewModel
- API Endpoints Overview
- Thirdβparty Integrations
- Sample Code Blocks & Snippets
- Usage Examples
- UML Diagrams
- Error Handling & Return Types
- Conclusion & Next Steps
1. Overview & Purpose
This Razor Page (TimesheetList.cshtml) is part of the FieldLog feature in the IrbyImaging application. It provides:
- π Filtering: Select by date and employee.
- π Listing: Display timesheet entries in a structured table.
- π Dynamic: Uses AJAX to fetch filtered data without reloading the page.
2. Dependencies & Technologies
| Category | Tools / Libraries |
|---|---|
| Frontend Framework | ASP.NET Core Razor Pages |
| UI Components | Syncfusion EJ2 (DatePicker & DropDownList) |
| Styling | Tailwind CSS, Font Awesome (CDNs) |
| Scripting | jQuery |
3. File Structure & Location
IrbyImaging/
βββ Views/
βββ FieldLog/
βββ TimesheetList.cshtml β This file
4. Key Functional Areas
4.1 Filter Section π οΈ
<div class="grid grid-cols-3 gap-4 mb-6">
<!-- Work Date -->
<div>
<label>Work Date</label>
<ejs-datepicker id="searchDate" placeholder="Select Date"></ejs-datepicker>
</div>
<!-- Employee -->
<div>
<label>Employee</label>
<ejs-dropdownlist
id="searchEmployee"
dataSource="@Model.Employees"
placeholder="Select Employee"
allowFiltering="true">
<e-dropdownlist-fields text="Text" value="Value"></e-dropdownlist-fields>
</ejs-dropdownlist>
</div>
<!-- Search Button -->
<div>
<button id="searchButton" class="action-button">Search Timesheets</button>
</div>
</div>
ejs-datepicker: Syncfusion date picker for selecting the work date.ejs-dropdownlist: Syncfusion dropdown bound toModel.Employees.- Search Button: Triggers an AJAX call to filter data.
4.2 Timesheet Table ποΈ
<table class="min-w-full leading-normal">
<thead>
<tr>
<th>Timesheet ID</th>
<th>Crew ID</th>
<th>Employee</th>
<th>Work Date</th>
<th>Regular</th>
<th>Overtime</th>
<th>Double Time</th>
<th>Per Diem</th>
</tr>
</thead>
<tbody id="timesheetTableBody">
@* Server-side rendering for initial load *@
@if (Model?.Timesheets != null)
{
@foreach (var ts in Model.Timesheets)
{
foreach (var empTs in ts.EmployeeTimesheets)
{
foreach (var entry in empTs.WorkEntries)
{
<tr>
<td>@ts.TimesheetId</td>
<td>@ts.CrewId</td>
<td>@empTs.EmployeeId</td>
<td>@entry.WorkDate.ToString("MM/dd/yyyy")</td>
<td>@entry.RegularHours</td>
<td>@entry.OvertimeHours</td>
<td>@entry.DoubletimeHours</td>
<td>@entry.PerDiemRate</td>
</tr>
}
}
}
}
else
{
<tr>
<td colspan="8" class="text-center">No timesheets found.</td>
</tr>
}
</tbody>
</table>
- Column Definitions: Clearly labeled, sortable via CSS utils.
#timesheetTableBody: Target for AJAX-based DOM updates.
4.3 AJAX Filter Functionality π
$(document).ready(function () {
$('#searchButton').click(function () {
const searchDate = $('#searchDate').val();
const searchEmployee = $('#searchEmployee').val();
$.ajax({
url: '/TimeEntry/GetFilteredTimesheets',
type: 'GET',
data: { searchDate, searchEmployee },
success: function (data) {
$('#timesheetTableBody').empty();
if (data && data.length) {
data.forEach(function (ts) {
ts.employeeTimesheets.forEach(function (empTs) {
empTs.workEntries.forEach(function (we) {
const row = `
<tr>
<td>${ts.timesheetId}</td>
<td>${ts.crewId}</td>
<td>${empTs.employeeId}</td>
<td>${new Date(we.workDate).toLocaleDateString()}</td>
<td>${we.regularHours}</td>
<td>${we.overtimeHours}</td>
<td>${we.doubletimeHours}</td>
<td>${we.perDiemRate}</td>
</tr>`;
$('#timesheetTableBody').append(row);
});
});
});
} else {
$('#timesheetTableBody').append(`
<tr><td colspan="8" class="text-center">No timesheets found.</td></tr>
`);
}
},
error: function (err) {
console.error('Error fetching timesheets:', err);
}
});
});
});
- Event: Click on Search button
- AJAX: GET β
/TimeEntry/GetFilteredTimesheets - Update: Rebuilds table rows dynamically
4.4 Styles & Theming π¨
.main-header {
background-color: #11467e;
color: white;
padding: 1.5rem;
border-radius: .5rem .5rem 0 0;
}
.action-button {
background-color: #11467e !important;
}
.action-button:hover {
background-color: #0d3563 !important;
}
.e-input-group { height: auto !important; }
.e-dropdown-popup { z-index: 1000 !important; }
- Mix of Tailwind utility classes and custom CSS for brand consistency.
5. Data Models & ViewModel
public class TimeEntryListViewModel
{
public IEnumerable<Timesheet> Timesheets { get; set; }
public List<SelectListItem> Employees { get; set; }
}
public class Timesheet
{
public int TimesheetId { get; set; }
public int CrewId { get; set; }
public List<EmployeeTimesheet> EmployeeTimesheets { get; set; }
}
public class EmployeeTimesheet
{
public int EmployeeId { get; set; }
public List<WorkEntry> WorkEntries { get; set; }
}
public class WorkEntry
{
public DateTime WorkDate { get; set; }
public decimal RegularHours { get; set; }
public decimal OvertimeHours { get; set; }
public decimal DoubletimeHours { get; set; }
public decimal PerDiemRate { get; set; }
}
- ViewModel: Binds to the page.
- Hierarchical: Timesheet β EmployeeTimesheet β WorkEntry.
6. API Endpoints Overview
| Method | Route | Params | Returns |
|---|---|---|---|
| GET | /TimeEntry/GetFilteredTimesheets |
searchDate (string), searchEmployee (string) |
JSON array of timesheets |
Example Response:
[{
"timesheetId": 101,
"crewId": 12,
"employeeTimesheets": [
{
"employeeId": 2001,
"workEntries": [
{
"workDate": "2024-07-15T00:00:00",
"regularHours": 8,
"overtimeHours": 1.5,
"doubletimeHours": 0,
"perDiemRate": 20.00
}
]
}
]
}]
7. Thirdβparty Integrations π
- Syncfusion EJ2:
<ejs-datepicker><ejs-dropdownlist>
- Tailwind CSS: Utility-first styling
- Font Awesome: Icons support via CDN
- jQuery: DOM manipulation & AJAX
8. Sample Code Blocks & Snippets
Razor Page Declaration
@page
@model IrbyImaging.Models.TimeEntryListViewModel
@addTagHelper *, Syncfusion.EJ2
@{
Layout = "~/Views/Shared/_TimeLayout.cshtml";
}
Table Row Generation (Razor)
@foreach (var ts in Model.Timesheets)
{
foreach (var empTs in ts.EmployeeTimesheets)
{
foreach (var we in empTs.WorkEntries)
{
<tr>
<td>@ts.TimesheetId</td>
<td>@ts.CrewId</td>
<td>@empTs.EmployeeId</td>
<td>@we.WorkDate:MM/dd/yyyy</td>
<td>@we.RegularHours</td>
<td>@we.OvertimeHours</td>
<td>@we.DoubletimeHours</td>
<td>@we.PerDiemRate</td>
</tr>
}
}
}
9. Usage Examples π―
- Navigate to the Timesheet List page (e.g.,
/FieldLog/TimesheetList). - Select a date and/or employee.
- Click Search Timesheets.
- Review the filtered results in the table.
- No results? A βNo timesheets found.β message appears.
10. UML Diagrams π
classDiagram
TimeEntryListViewModel --> "0..*" Timesheet : Timesheets
TimeEntryListViewModel --> "0..*" SelectListItem : Employees
Timesheet --> "0..*" EmployeeTimesheet : EmployeeTimesheets
EmployeeTimesheet --> "0..*" WorkEntry : WorkEntries
class Timesheet { +int TimesheetId; +int CrewId; }
class EmployeeTimesheet { +int EmployeeId; }
class WorkEntry {
+DateTime WorkDate
+decimal RegularHours
+decimal OvertimeHours
+decimal DoubletimeHours
+decimal PerDiemRate
}
class SelectListItem { +string Text; +string Value; }
11. Error Handling & Return Types π§
- AJAX Errors: Logged via
console.error. - Empty Data: Renders a single row with βNo timesheets found.β
- Null Model: Checked serverβside to prevent exceptions.
12. Conclusion & Next Steps π
TimesheetList.cshtml offers a robust, interactive interface for viewing and filtering timesheet data.
Possible Enhancements:
- β Pagination for large datasets
- π₯ Export to CSV/PDF
- βοΈ Inline Editing of entries
- π SignalR for realβtime updates
Enjoy building on this foundation! π