πŸ“‹ TimesheetList.cshtml Documentation

Path: IrbyImaging/Views/FieldLog/TimesheetList.cshtml
Purpose: Render and filter submitted timesheets in a dynamic, user-friendly table.


πŸ“‘ Table of Contents

  1. Overview & Purpose
  2. Dependencies & Technologies
  3. File Structure & Location
  4. Key Functional Areas
    4.1 Filter Section
    4.2 Timesheet Table
    4.3 AJAX Filter Functionality
    4.4 Styles & Theming
  5. Data Models & ViewModel
  6. API Endpoints Overview
  7. Third‑party Integrations
  8. Sample Code Blocks & Snippets
  9. Usage Examples
  10. UML Diagrams
  11. Error Handling & Return Types
  12. 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 to Model.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 🎯

  1. Navigate to the Timesheet List page (e.g., /FieldLog/TimesheetList).
  2. Select a date and/or employee.
  3. Click Search Timesheets.
  4. Review the filtered results in the table.
  5. 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! πŸš€