📄 IrbyImaging/Views/IView/Index.cshtml Documentation


🚀 Table of Contents

  1. Overview & Purpose
  2. Dependencies & Technologies
  3. View Models & Data Models
  4. Key Functional Areas
    4.1. Filtering & Form Submission
    4.2. Summary Grids (TreeGrid3, 4 & 5)
    4.3. Main & Child Grids
    4.4. Modal & AJAX Interactions
    4.5. Export & Toolbar Controls
  5. Helper Methods & Utilities
  6. API Endpoints Overview
  7. Third‑party Integrations
  8. Sample Code Blocks
  9. Usage Examples
  10. UML Diagram (Data Model)
  11. Conclusion

📝 Overview & Purpose

This Razor view (Index.cshtml) renders an interactive dashboard for Irby Construction Company financials. It allows users to:

  • Filter performance by reporting month/year, type of work, lead, and customer.
  • Display summary metrics (monthly, YTD, DSO analysis, balance) in top‑level grids.
  • Drill down into detailed job and type‑of‑work data via child grids.
  • View modals for detailed breakdowns of revenue, cost, margin, and man‑hours.
  • Export data to Excel or PDF.

Intended for project managers and executives to monitor revenue, cost, margin, and utilization.


🔧 Dependencies & Technologies

Technology / Library Purpose
ASP.NET Core MVC (Razor) View rendering & server‑side binding
Syncfusion EJ2 Grids & TreeGrid Interactive grids with grouping, child grids, exports
jQuery DOM manipulation & AJAX
Bootstrap 4 Responsive layout & modals
DataTables + Buttons (Commented out) alternative table enhancements
jszip & pdfmake Client‑side Excel/PDF generation
MetisMenu, SimpleBar, Waves UI enhancements (sidebar, scrollbars, ripple effects)

🗃️ View Models & Data Models

The view relies on several ViewBag properties supplied by the IViewController:

ViewBag Key Type Description
YearMonth IEnumerable<SelectListItem> Reporting periods
TypeOfWork IEnumerable<SelectListItem> Categories of work
Lead IEnumerable<SelectListItem> Project leads
Customer IEnumerable<SelectListItem> Customer list
datasource IEnumerable<WorkSummary> Main type‑of‑work summary
datasource1 IEnumerable<WorkSummary> Lead-level summary
datasource2 IEnumerable<WorkSummary> Customer-level summary
datasource3 IEnumerable<MonthlySummary> Month vs YTD financials
datasource4 IEnumerable<DSOAnalysis> Days‑Sales‑Outstanding analysis
datasource5 IEnumerable<BalanceSummary> Balance summary
datasource7,8,9 IEnumerable<JobDetail> Child grids for Type, Lead, Customer detail

Example Data Model (WorkSummary)

public class WorkSummary {
  public string Type { get; set; }
  public decimal Revenue { get; set; }
  public decimal Cost { get; set; }
  public decimal Margin => Revenue - Cost;
  public double MarginPct { get; set; }
  public decimal YTDRevenue { get; set; }
  public decimal YTDCost { get; set; }
  public double RevPctOfTotal { get; set; }
  public double MarPctOfTotal { get; set; }
  public double ManHours { get; set; }
  public List<JobDetail> Children { get; set; }
}

🔑 Key Functional Areas

4.1 ✏️ Filtering & Form Submission

  • Four ejs-multiselect controls (YearMonth, TypeOfWork, Lead, Customer) allow multi‑select filtering.
  • A Submit button posts filters to IView/Index (POST).
  • On submit, the controller repopulates ViewBag and returns the updated view.

4.2 🧮 Summary Grids (TreeGrid3, 4 & 5)

Three top‑level grids display:

  1. Monthly vs YTD (TreeGrid3)
  2. DSO Analysis (TreeGrid4)
  3. Balance Summary (TreeGrid5)

Common features:

  • /ejs-grid/ components
  • allowExcelExport="true", allowPdfExport="true"
  • autoFitColumns via dataBound event

4.3 📊 Main & Child Grids

  • Main TreeGrid (id="TreeGrid") shows Type of Work breakdown.
  • Lead TreeGrid (id="TreeGrid1") groups by Lead.
  • Customer TreeGrid (id="TreeGrid2") groups by Customer.

All three use a childGrid configuration:

childGrid = new Grid() {
  DataSource = ViewBag.datasource7,
  FrozenColumns = 2,
  EnableInfiniteScrolling = true,
  Columns = new List<GridColumn> { /* ... */ }
};
  • Columns include templates for clickable links (#typetemplate, #typetemplate2, etc.)
  • Stacked columns for Revenue/Cost/Margin/Percentage metrics

4.4 🖼️ Modal & AJAX Interactions

  • Several <script id="typetemplateX"> define HTML templates with anchors.
  • Clicking a metric (e.g. revenue MTD) triggers an AJAX GET to endpoints like:
    • /IView/balancesModal
    • /IView/balancesCostModal
    • /IView/balancesHoursModal
    • /IView/balancesModalYTD
  • Results are injected into #myModalContent and shown in a Bootstrap modal.

4.5 📤 Export & Toolbar Controls

  • Custom toolbarClick handles PDF/Excel export for the main grid.
  • onChange toggles collapsedStatePersist (persist expand/collapse).
  • Built‑in Syncfusion export:
    if (args.item.id === 'TreeGrid_pdfexport') grid.pdfExport();
    if (args.item.id === 'TreeGrid_excelexport') grid.excelExport();
    

🛠 Helper Methods & Utilities

function dataBound(args) {
  // Auto-fit columns after data bound
  this.autoFitColumns([...]);
}
function dataBound11(args) {
  // Auto-fit child grid columns
  this.autoFitColumns([...]);
}
function toolbarClick(args) { /* PDF/Excel logic */ }
function onChange(args) { collapsedStatePersist = args.checked; }

These ensure consistent layout and export behavior across all grids.


📡 API Endpoints Overview

Endpoint Method Description
/IView/Index GET/POST Loads the main dashboard view
/IView/getAccountBalanceDetail/{JobNumber} GET Partial: JOB detail drill‑down (Type & Name)
/IView/getAccountBalanceDetailType/{Type} GET Partial: Type‑of‑work detail modal
/IView/balancesModal GET Partial: Revenue MTD detail
/IView/balancesCostModal GET Partial: Cost MTD detail
/IView/balancesHoursModal GET Partial: Man‑hours detail
/IView/balancesModalYTD GET Partial: Revenue YTD detail
/IView/balancesCostModalYTD GET Partial: Cost YTD detail

Each returns a PartialView rendered inside the modal container.


🌐 Third‑party Integrations

Library Usage
Syncfusion EJ2 (ejs-grid, ejs-multiselect) Comprehensive grid, dropdown & multiselect UI
jQuery Simplified AJAX and event handling
DataTables.js (commented) Alternative table features (buttons, export)
jszip & pdfmake Client‑side file generation
Bootstrap Modal & responsive grid containers
MetisMenu, SimpleBar, Node‑waves Sidebar navigation, custom scrollbars, ripple effects

📋 Sample Code Blocks

1. Defining a Child Grid

@{
  var childGrid = new Syncfusion.EJ2.Grids.Grid() {
    DataSource = ViewBag.datasource7,
    FrozenColumns = 2,
    Columns = new List<Syncfusion.EJ2.Grids.GridColumn> {
      new Syncfusion.EJ2.Grids.GridColumn() {
        Field = "JobNumber",
        HeaderText = "Job#",
        Template = "#typetemplate",
        TextAlign = TextAlign.Center
      },
      // ... more columns ...
    }
  };
}

2. Revenue MTD Template & AJAX

<script id="typetemplate2" type="text/x-template">
  <a href="javascript:void(0);" id="revenueMTD" class="anchorDetailRev"
     data-id=${JobNumber} data-Year=${ReportYear}/${ReportMonth}>
     $${Revenue}
  </a>
</script>

<script>
$(document).on('click', '#revenueMTD', function() {
  $.get('/IView/balancesModal', {
    id: $(this).data('id'),
    Year: $(this).data('Year')
  }).done(function(html) {
    $('#myModalContent').html(html);
    $('#myModal').modal('show');
  });
});
</script>

📈 Usage Examples

  1. Load the page via GET /IView/Index.
  2. Select filters from the dropdowns (e.g., March 2024, Electrical).
  3. Click Submit: the view reloads with updated ViewBag.datasource*.
  4. Inspect summary in the top row of grids.
  5. Expand a Type or Lead row to see child jobs.
  6. Click a Revenue link to view detailed modal.
  7. Use the toolbar to export the main grid to PDF/Excel.

🗂 UML Diagram (Data Model)

+-------------------+
|   WorkSummary     |
+-------------------+
| - Type: string    |
| - Revenue: decimal|
| - Cost: decimal   |
| - Margin: decimal |
| - MarginPct: dbl  |
| - YTDRevenue: dec |
| - YTDCost: dec    |
| - RevPctOfTotal: dbl |
| - Children: List<JobDetail> |
+-------------------+
           |
           | 1..*
           v
+-------------------+
|    JobDetail      |
+-------------------+
| - JobNumber: str  |
| - JobName: str    |
| - Revenue: decimal|
| - Cost: decimal   |
| - ManHours: dbl   |
+-------------------+

✅ Conclusion

This Index.cshtml view is the cornerstone of the Irby Construction interactive reporting module. It leverages Syncfusion EJ2 grids for high‑performance data presentation, AJAX modals for deep dives, and client‑side exports for sharing. By following the structure outlined above, developers can:

  • Extend filters or data sources
  • Customize grid templates and styles
  • Integrate additional drill‑down endpoints
  • Maintain a consistent UX with auto‑fitting and theming

Ready to empower your team with actionable financial insights! 🎉