π Fringe Benefit Sheet View Documentation
Welcome to the comprehensive documentation of the FringeBenefitSheet.cshtml view in the IrbyImaging application. This Razor view renders a dynamic Fringe Benefit timesheet interface for mechanics, allowing users to select jobs, pick pay period ending dates (PPED), load employee data, inspect detailed benefit and hour breakdowns, and finally export the results.
π Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- Model & ViewData
- Layout & Structure
- HTML & Syncfusion Components
- CSS & Styling
- JavaScript Logic & Key Functions
- Helper Methods & Utilities
- API Endpoints Overview
- Third-Party Integrations
- UML Diagram
- Usage Example
- Conclusion
1. Overview & Purpose
This view provides a Fringe Benefit Sheet for mechanicsβ timesheets.
Key goals:
- π― Select a Job and PPED Date.
- π Search employees assigned to that job & date.
- π Display dynamic table with:
- Basic employee info
- Fringe requirement vs. actual earned benefits
- Weekly hours & gross pay breakdown
- π Calculate totals: employees count, job hours, cash due
- πΎ Export:
- Fringe Benefit Excel sheet
- CERT PR payroll file
2. Dependencies & Technologies
| Category | Library / Framework | Purpose |
|---|---|---|
| ASP.NET MVC / Razor | @model, ViewData, Layout |
Page templating |
| Syncfusion EJ2 | ejs-dropdownlist, ejs-datepicker |
Rich UI dropdowns & date pickers |
| jQuery & AJAX | $.ajax, DOM manipulation |
Data fetching & dynamic rendering |
| DataTables | Buttons, responsive, export features | Table enhancements (sorting, export) |
| Bootstrap 4 & 5 | CSS grid, modals, icons (bootstrap-icons) |
Layout & icons |
| Dropzone | dropzone.js |
(Unused in this view but loaded) |
| Newtonsoft.Json | JSON serialization | Data exchange |
3. Model & ViewData
@model IrbyImaging.DomainClasses.MechanicTimesheet
@using IrbyImaging.DomainClasses
@{
ViewData["Title"] = "Fringe Benefit Sheet";
Layout = "~/Views/Shared/_TimeLayout.cshtml";
}
- Model:
MechanicTimesheetcontains properties such as JobId, SelectedDate, Employees, etc. - ViewBag.Jobs: Populated in the controller to drive the Job dropdown.
4. Layout & Structure
_FringeBenefitSheet.cshtml
ββ @section styles β‘οΈ External CSS & Syncfusion theming
ββ <head> scripts/styles β‘οΈ CDN references
ββ <h2> Title β‘οΈ βFringe Benefit Sheetβ
ββ .mainSearch β‘οΈ Filters: Job dropdown, Datepicker, Search & Export buttons
ββ #timesheetContent β‘οΈ Hidden container, shows after Search
β ββ .summary-header β‘οΈ Totals: #employees, job hours, cash due
β ββ .table-container β‘οΈ Employee DataTable
ββ <template>#employeeRowTemplate β‘οΈ Row + Expandable details
ββ #loadingModal & #spinnerContainer β‘οΈ UX feedback
ββ CSS `<style>` blocks β‘οΈ Custom styling
ββ `<script>` blocks β‘οΈ Core JS logic
5. HTML & Syncfusion Components
5.1 Job Dropdown
<ejs-dropdownlist id="Job"
dataSource="@(ViewBag.Jobs)"
placeholder="Select a Job"
allowFiltering="true"
change="onJobChange">
<e-dropdownlist-fields text="Text" value="Value"></e-dropdownlist-fields>
</ejs-dropdownlist>
- dataSource: List of
{ Text, Value }job options - onJobChange: JS handler captures
selectedJob
5.2 Datepicker (PPED)
<ejs-datepicker id="datepicker"
showClearButton="true"
placeholder="Select a Date">
</ejs-datepicker>
- Only Sundays are enabled via
renderDayCell
5.3 Search & Action Buttons
- Search:
searchEmployees() - Save & Export:
- Save Fringe β
submitData() - Generate CERT PR β
generateFile()
- Save Fringe β
6. CSS & Styling
- Flex layout for filters (
.mainSearch) - Sticky headers & tables auto-scroll
- Color themes via CSS variables (
--primary-color,--border-color) - Animations for toggles (
.toggle-btn i.rotate) - Detail panels absolutely positioned within row
Tip: The custom CSS ensures a responsive, clean UX for large tables.
7. JavaScript Logic & Key Functions
7.1 Global Initialization
- Globals:
selectedJob,selectedDate - Close dropdowns: Click outside closes benefit/hour details
- Currency formatting:
setupCurrencyFormatting()applies$& decimals - Datepicker change: Captures
selectedDate
7.2 Search & Data Fetching
function searchEmployees() {
if (!selectedJob || !selectedDate) {
alert('Select job and PPED date');
return;
}
showLoadingModal();
$.ajax({
url: '@Url.Action("GetEmployeesByJob","TimeEntry")',
data: { jobId: selectedJob, selectedDate: selectedDate.toISOString().split('T')[0] },
success: function(data) {
hideLoadingModal();
renderEmployees(data);
},
error: function() {
hideLoadingModal();
alert('Failed to fetch employees.');
}
});
}
- AJAX GET returns JSON array of employees+benefits data
- renderEmployees() orchestrates the dynamic row insertion
7.3 Row Rendering & Templates
#employeeRowTemplate: HTML<template>for:.employee-row.benefits-row(hidden by default)
createEmployeeNodes(employeeData)- Clones template, fills
<input>&<span>fields - Binds toggle/delete events
- Sets up tabs & dropdowns
- Clones template, fills
7.4 Dropdown Toggles & Detail Popups
- Benefits (
.benefits-dropdown-btn) - Daily Hours (
.hours-dropdown-btn) - Global click handler closes any open popups
- Individual toggle rotates caret icon & expands details
7.5 Calculations & Formatting
- Fringe Credits β Annualized Fringe
- Cash in Lieu = max(0, FringeRequirement β AnnualizedFringe)
- Cash Due = ActualHours Γ CashInLieu
- Total Job Hours & Total Cash Due aggregation
On every blur or dynamic row addition, listeners recalculate and format with $ and commas.
7.6 Submission & Export
- submitData() β
GET /TimeEntry/SaveFringeBenefits2β returns Excel blob β triggers download - generateFile() β
GET /TimeEntry/GeneratePayrollFileβ returns CERT PR blob - buildFringeBenefitsObject() β collects all fields into a JSON payload
- POST /TimeEntry/SaveFringeBenefits β saves data server-side
8. Helper Methods & Utilities
| Function | Description |
|---|---|
showLoadingModal() |
Display βPlease waitβ¦β overlay |
formatDate() |
MM-DD-YYYY formatting for day headers |
setupPlaceholderBehavior() |
Clear/show placeholder="0.00" on focus/blur |
setupTabs() |
Wire up βFringe Benefitsβ / βWeekly Hoursβ tabs |
attachEmployeeCalculationListeners() |
Recalculate on manual input changes |
9. API Endpoints Overview
| Endpoint | Method | Description |
|---|---|---|
/TimeEntry/GetEmployeesByJob |
GET | Returns JSON array of employees + benefits |
/TimeEntry/SaveFringeBenefits2 |
GET | Streams Excel file for fringe benefits export |
/TimeEntry/GeneratePayrollFile |
GET | Streams CERT PR payroll file |
/TimeEntry/SaveFringeBenefits |
POST | Saves fringe benefits JSON payload |
10. Third-Party Integrations
- Syncfusion EJ2: Rich controls (DropdownList, DatePicker)
- DataTables: Table export (CSV, PDF, Print)
- Bootstrap Icons: Carets & trash icons
- Dropzone: File uploads (though not used here)
11. UML Diagram
flowchart TD
A[User Interface]
A --> B[Select Job & Date]
B --> C[searchEmployees()]
C --> D[AJAX β GetEmployeesByJob]
D --> E[renderEmployees(data)]
E --> F[Row Templates] --> G[Toggle Benefits / Hours]
E --> H[calculate totals]
H --> A(Updated Summary)
A --> I{Save / Generate}
I --> J[submitData() / generateFile()]
J --> K[Excel / CERT PR Download]
12. Usage Example
# 1. Navigate to Fringe Benefit Sheet page
GET /TimeEntry/FringeBenefitSheet
# 2. Select a job and PPED date (Sunday)
# 3. Click "Search" β Employees load dynamically
# 4. Expand rows to view benefits & hours details
# 5. Click "Save and Create Fringe Benefit Sheet" β downloads .xlsx
# 6. Click "Generate CERT PR File" β downloads .pr file
13. Conclusion
The FringeBenefitSheet.cshtml view is a feature-rich interface that:
- Leverages Syncfusion for polished UI
- Uses AJAX to dynamically fetch and render data
- Provides inline calculations & formatting
- Enables export of fringe benefit sheets and payroll files
You can extend this template by:
- Adding server-side validation
- Integrating real-time updates (SignalR)
- Customizing export formats
Happy coding! π