PayrollDraft.cshtml 📑
Location:
IrbyImaging/Views/FieldLog/PayrollDraft.cshtml
Purpose: A dynamic Daily Time Sheet view for field crews, enabling selection of crew, date, employees, equipment, signatures, and submission of a complete timesheet via AJAX.
📋 Table of Contents
- Overview & Purpose
- Dependencies & Technologies
- View Model & Data Models
- Page Layout & Structure
- Key Functional Areas
5.1 Crew & Date Selection
5.2 Signature Capture
5.3 Employee Time Entries
5.4 Equipment Time Entries
5.5 Comments & Submission - Helper Methods & Utilities
- API Endpoints Overview
- Third‑party Integrations
- Sample Workflow
- UML Component Diagram
- Conclusion
1. Overview & Purpose 🌟
This Razor view renders a Daily Time Sheet for field crews to:
- Select a Crew and Work Date
- Capture the Foreman’s Signature
- Add multiple Employees and record their daily work entries (job, hours, meals, etc.)
- Add multiple Equipment entries (odometer, work/idle hours)
- Write Comments/Progress notes
- Submit the entire timesheet as JSON to the server (
/TimeEntry/SubmitFieldTimesheet)
The page is highly dynamic, using Syncfusion EJ2 components, jQuery, custom dropdowns, and signature capture. It supports copying, filtering, lazy‑loading, and validation.
2. Dependencies & Technologies 🛠️
| Library / Framework | Purpose |
|---|---|
| ASP.NET MVC (.cshtml) | Server‐side view rendering |
| jQuery (v3.7.1) | DOM manipulation, AJAX |
| Tailwind CSS (v2.2.19) | Utility‐first styling |
| Font Awesome (v6.4.0) | Icon fonts (copy, remove, toggle) |
| SignaturePad (v4.1.7) | Canvas‐based signature capture |
| Syncfusion EJ2 (Inputs) | DatePicker, TimePicker, DropdownList |
JSON.NET / Razor Json.Serialize |
Serializing ViewModel data to JS |
3. View Model & Data Models 📦
Model bound: IrbyImaging.UI.Models.CreateFieldTimesheetViewModel
Key properties (inferred):
| Property | Type | Description |
|---|---|---|
Employees |
List<SelectListItem> |
All available employees |
Jobs |
List<SelectListItem> |
Job numbers |
CostCodes |
List<SelectListItem> |
Cost codes (filtered by job) |
Classes |
List<SelectListItem> |
Classes (filtered by job/cost code) |
WorkOrders |
List<SelectListItem> |
Work orders |
UnionCodes |
List<SelectListItem> |
Union codes |
PayCodes |
List<SelectListItem> |
Pay codes |
Equipment |
List<SelectListItem> |
Equipment catalog |
Crews (ViewBag) |
List<SelectListItem> |
Crews available for selection |
EmployeeTimesheets (ViewBag) |
JSON array | Pre‐existing entries (for edit/copy) |
EquipmentTimesheets (ViewBag) |
JSON array | Pre‐existing equipment entries |
CrewId, Comments (ViewBag) |
scalar values | For editing existing timesheet |
On page load, the ViewModel data is serialized into window.ViewBag and window.timesheetModel for JavaScript consumption.
4. Page Layout & Structure 🏗️
@using Syncfusion.EJ2
@model CreateFieldTimesheetViewModel
@{
ViewData["Title"] = "Daily Timesheet";
Layout = "~/Views/Shared/_TimeLayout.cshtml";
}
<!-- External libraries: jQuery, Tailwind, FontAwesome, SignaturePad, Syncfusion -->
<div class="time-container mx-auto p-6 bg-white" style="width:95%;">
<h1 class="main-header">Daily Time Sheet</h1>
<!-- Grid: Crew ID, Work Date, Foreman's Signature -->
<!-- Employees Section -->
<!-- Employee Template (hidden) -->
<!-- Equipment Section -->
<!-- Equipment Template (hidden) -->
<!-- Comments -->
<ejs-textbox id="comments" multiline="true"></ejs-textbox>
<button id="submitTimesheet" class="action-button">Save Timesheet</button>
</div>
- Templates (
.employee-template,.equipment-template) are hidden clones used for dynamic row insertion. - Syncfusion controls are appended to placeholder
<div>or<input>elements.
5. Key Functional Areas 🔑
5.1 Crew & Date Selection 🎛️
- Crew Dropdown
crewDropdown = new ej.dropdowns.DropDownList({ dataSource: window.ViewBag.Crews, fields: { text: 'CrewName', value: 'CrewId' }, placeholder: 'Select Crew', allowFiltering: true, enableVirtualization: true }); crewDropdown.appendTo("#crewId"); - Work Date Picker
<ejs-datepicker id="commonWorkDate" placeholder="Select Work Date" required="true"></ejs-datepicker>
On crew change, two AJAX calls populate the Employees and Equipment containers:
- GET
/TimeEntry/GetEmployeesByCrew?crewId=... - GET
/TimeEntry/GetEquipmentByCrew?crewId=...
5.2 Signature Capture ✍️
- A
<canvas id="signaturePad">is initialized with SignaturePad. - Clear and Save buttons allow erasing or storing the signature as a base64 data URL.
5.3 Employee Time Entries 👷♂️
- Each employee row has:
- Syncfusion Employee dropdown
- Toggle (show/hide entries) & Remove icons
- Copy icon to duplicate an existing row
- Totals (day/week)
- Work Entry sub‐rows support:
- Syncfusion Job No., Cost Code, Class, Work Order, Union Code, Pay Code, Per Diem Type, Transfer dropdowns
- Numeric inputs: Regular, OT, DT, Per Diem Rate
- Syncfusion
TimePicker: Start Time, End Time - NumericTextBox: Lunch Hour
- Checkboxes: Breakfast, Lunch, Dinner, Motel
- Remove icon per entry
- Dynamic creation via
addNewEmployee()andaddNewEmployeeWorkEntry() - Copying via
copyAllEmployeeWorkEntries()©EmployeeRow()
5.4 Equipment Time Entries 🚜
- Similar pattern to employees, with:
- Syncfusion Equipment dropdown
- Toggle, Remove, Copy icons
- Totals: Worked/Idle (day/week)
- Equipment Work Entry:
- Syncfusion Job No., Cost Code
- Inputs: Odometer, Meter Hours, Worked, Idle
- Managed by
addNewEquipment(),addNewEquipmentEntry(), and copy helpers
5.5 Comments & Submission 💬
- Comments via Syncfusion
ejs-textbox(multiline) - Submit button (
#submitTimesheet) triggers:const timesheetObj = buildTimesheetObject(); $.ajax({ url: '/TimeEntry/SubmitFieldTimesheet', type: 'POST', data: JSON.stringify(timesheetObj), contentType: 'application/json', success: () => alert("Saved!"), error: (xhr) => alert(xhr.responseText) }); buildTimesheetObject()collects:- CrewId, Work Date, Comments, Signature
- Each Employee → an array of WorkEntries
- Each Equipment → an array of EquipmentEntries
6. Helper Methods & Utilities 🔧
| Function | Description |
|---|---|
generateUniqueId(prefix) |
Unique suffix for dynamic element IDs |
generateGUID() |
Quick GUID generator for Timesheet & Entry IDs |
safeGetText(dropdown) |
Safely read text from a Syncfusion dropdown |
loadDropdownOptions($el, bag,…) |
Lazy‐load & filter custom dropdowns |
getDataSourceName(type) |
Map element type to ViewBag key |
initCustomDropdowns($container) |
Initialize custom <div class="custom-dropdown"> |
filterEmployeeCostCode() |
Filter cost codes by Job GUID |
filterEmployeeClass() |
Filter classes by Job GUID & Cost Code |
filterEquipmentCostCodes() |
Filter equip. cost codes by Job GUID |
addNewEmployee() |
Append a new Employee row to #employeesContainer |
addNewEmployeeWorkEntry() |
Append a new work entry under an employee row |
addNewEquipment() |
Append a new Equipment row to #equipmentContainer |
addNewEquipmentEntry() |
Append a new equipment work entry |
copyWorkEntryData() |
Copy data from one work‐entry to another |
copyAllEmployeeWorkEntries() |
Bulk‑copy work entries when duplicating employee row |
copyEmployeeRow() |
Duplicate an entire employee row |
copyAllEquipmentEntries() |
Bulk‑copy equipment work entries |
copyEquipmentRow() |
Duplicate an entire equipment row |
updateTotalHours() |
Recalculate employee day/week totals |
calculateWeekHours() |
Derive weekly totals based on current date |
updateTotalEquipmentHours() |
Recalculate equipment day/week totals |
calculateWeekEquipmentHours() |
Derive weekly equipment totals |
7. API Endpoints Overview 📡
| Endpoint | HTTP | Payload | Returns |
|---|---|---|---|
/TimeEntry/GetEmployeesByCrew?crewId={id} |
GET | — | List of employees (JSON) |
/TimeEntry/GetEquipmentByCrew?crewId={id} |
GET | — | List of equipment (JSON) |
/TimeEntry/SubmitFieldTimesheet |
POST | JSON‑serialized timesheetObj |
{ success: true, message } |
8. Third‑party Integrations 🔌
- Syncfusion EJ2
- DropDownList, DatePicker, TimePicker, NumericTextBox, TextBox
- Virtualization & filtering for large lists
- SignaturePad
- Canvas‑based free‑hand signature capture
- Tailwind CSS
- Rapid, responsive utility classes
- Font Awesome
- Action icons for toggling, copying, deleting
- jQuery
- DOM events, AJAX, dynamic cloning
9. Sample Workflow 🏃♂️
- User selects a Crew
- System calls
/GetEmployeesByCrew&/GetEquipmentByCrew - Employees & equipment rows render automatically
- For each Employee:
- Select Job No. → filters Cost Codes & Classes
- Enter hours, meals, times
- For each Equipment:
- Select Equipment → add work entries
- Foreman signs in the canvas area
- (Optional) Write Comments
- Click Save Timesheet → AJAX POST → server persists
10. UML Component Diagram 📊
graph LR
A[User] --> B[PayrollDraft View]
B --> C[Crew Dropdown]
B --> D[Work Date Picker]
B --> E[SignaturePad Canvas]
B --> F[EmployeesContainer]
B --> G[EquipmentContainer]
B --> H[Comments TextBox]
B --> I[Save Button]
C --> J[/GetEmployeesByCrew]
C --> K[/GetEquipmentByCrew]
I --> L[/SubmitFieldTimesheet]
11. Conclusion ✅
The PayrollDraft.cshtml view is a powerful, interactive timesheet interface tailored for field operations. It seamlessly integrates:
- Rich UI (Syncfusion, Tailwind, icons)
- Dynamic behaviors (cloning, filtering, copying)
- Offline signature capture
- AJAX‑driven data loading for crews, employees, equipment
- JSON‑based submission for robust server‐side processing
This single page encapsulates the full lifecycle of a daily timesheet—from crew assignment to final submission—in a responsive, user‑friendly experience.