πŸ“ 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

  1. Overview & Purpose
  2. Dependencies & Technologies
  3. Model & ViewData
  4. Layout & Structure
  5. HTML & Syncfusion Components
  6. CSS & Styling
  7. JavaScript Logic & Key Functions
  8. Helper Methods & Utilities
  9. API Endpoints Overview
  10. Third-Party Integrations
  11. UML Diagram
  12. Usage Example
  13. 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: MechanicTimesheet contains 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()

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:
    1. .employee-row
    2. .benefits-row (hidden by default)
  • createEmployeeNodes(employeeData)
    • Clones template, fills <input> & <span> fields
    • Binds toggle/delete events
    • Sets up tabs & dropdowns

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

  1. Fringe Credits β†’ Annualized Fringe
  2. Cash in Lieu = max(0, FringeRequirement – AnnualizedFringe)
  3. Cash Due = ActualHours Γ— CashInLieu
  4. 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! πŸš€