Operationstotalreport Documentation

Operations Total Report Controller Documentation

File: /controllers/operationstotalreport.php

Purpose: Comprehensive dashboard showing all business operations totals including sales, purchases, inventory, and financial summaries

Last Updated: December 20, 2024

Total Functions: 20+

Lines of Code: ~1,921

---

๐Ÿ“‹ Overview

The Operations Total Report Controller serves as a comprehensive business dashboard, aggregating data from all major business operations into a single view. It provides real-time totals for sales, purchases, returns, payments, collections, inventory, and financial positions.

Primary Functions

Related Controllers

---

๐Ÿ—„๏ธ Database Tables

Primary Operations Tables

Table NamePurposeKey Columns
**sellbill**Sales transactionssellbillid, sellbilldate, sellbillaftertotalbill, sellbilltotalpayed, conditions
**returnsellbill**Sales returnsreturnsellbillid, returnsellbilldate, returnsellbillaftertotalbill, conditions
**buybill**Purchase transactionsbuybillid, buybilldate, buybillaftertotalbill, conditions
**returnbuybill**Purchase returnsreturnbuybillid, returnbuybilldate, returnbuybillaftertotalbill, conditions
**savedaily**Cash register movementssavedailyid, savedailydate, savedailychangeamount, savedailychangetype
**clientdebtchange**Customer debt changesclientdebtchangeid, clientdebtchangedate, clientdebtchangeamount
**supplierdebtchange**Supplier debt changessupplierdebtchangeid, supplierdebtchangedate, supplierdebtchangeamount
### Financial Tables

Table NamePurposeKey Columns
**client**Customer balancesclientid, clientdebt, conditions
**supplier**Supplier balancessupplierid, suppliercurrentDebt, conditions
**expenses**Expense recordsexpensesid, expensesdate, expensesValue, expensestypeid
**storedetail**Inventory detailsstoredetailid, storedetailquantity, productid
---

๐Ÿ”‘ Key Functions

1. Default Dashboard - Complete Operations Summary

Location: Lines 423-507

Purpose: Generate comprehensive business operations dashboard

Process Flow:

1. Date Range Processing: Auto-detect business day based on settings

2. Cash Register Summary: Call search() for cash movements

3. Sales Analysis: Call showAll() for sales totals

4. Returns Tracking: Call returnshowAll() for return totals

5. Purchase Analysis: Call showBuyBill() for purchase totals

6. Purchase Returns: Call showBuyReturn() for purchase return totals

7. Collections Summary: Call showx() for customer collections

8. Payments Summary: Call showxDofat() for supplier payments

9. Debt Calculations: Calculate customer and supplier debt totals

10. Inventory Valuation: Calculate total inventory value (if enabled)

11. Expense Tracking: Sum expenses for the period

Key Variables:

---

2. search() - Cash Register Analysis

Location: Lines 516-877

Purpose: Analyze cash register movements and calculate totals

Function Signature:

function search($saveid, $processid, $startDate, $endDate)

Key Features:

---

3. showAll() - Sales Analysis

Location: Lines 895-1082

Purpose: Comprehensive sales bill analysis with discount and tax calculations

Key Calculations:

---

4. returnshowAll() - Returns Analysis

Location: Lines 1085-1300

Purpose: Sales return analysis with detailed calculations

---

5. showBuyBill() - Purchase Analysis

Location: Lines 1303-1484

Purpose: Purchase bill analysis with supplier tracking

---

6. Debt Tracking Functions

Location: Lines 1852-1873

function clientdebt() // Customer debt totals
function supplierdebt() // Supplier debt totals  

7. totalproduct() - Inventory Valuation

Location: Lines 1876-1919

Purpose: Calculate total inventory value using configurable pricing methods

Pricing Methods:

---

๐Ÿ”„ Workflows

Main Dashboard Workflow

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
START: Load Operations Dashboard
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
1Calculate Business Day Range
โ†’ Check reportsPlusHours setting
โ†’ Determine if current time is before/after cutoff
โ”‚ โ””โ”€โ†’ Set appropriate date range โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
2Execute All Analysis Functions (Parallel)
โ†’ search() - Cash register analysis
โ†’ showAll() - Sales analysis
โ†’ returnshowAll() - Returns analysis
โ†’ showBuyBill() - Purchase analysis
โ†’ showBuyReturn() - Purchase returns
โ†’ showx() - Customer collections
โ”‚ โ””โ”€โ†’ showxDofat() - Supplier payments โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
3Calculate Summary Totals
โ†’ clientdebt() - Total customer debt
โ†’ supplierdebt() - Total supplier debt
โ†’ totalproduct() - Inventory valuation
โ”‚ โ””โ”€โ†’ totalExpense - Expense totals โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ–ผ
โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
4Display Comprehensive Dashboard
โ”‚ โ””โ”€โ†’ operationstotalview/indexReport.html โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

---

๐Ÿงฎ Calculation Methods

Business Day Calculation

if (date('H') < $Programsetting->reportsPlusHours) {
    $start = $startYesterday;
    $end = $endYesterday;
} else {
    $start = $startToday;
    $end = $endToday;
}

Inventory Valuation

switch ($Programsettingdata->Inventoryevaluation) {
    case "first":
        $priceColumnName = 'productBuyPrice';
        break;
    case "last":
        $priceColumnName = 'lastbuyprice';
        break;
    case "mean":
        $priceColumnName = 'meanbuyprice';
        break;
    // ... additional methods
}
$totalprice = (float) $myStoredetailEx->getM5zonPrice($priceColumnName);

---

๐Ÿ”’ Security & Performance

Performance Considerations

Required Indexes

---

๐Ÿ“š Related Documentation

---

Documented By: AI Assistant

Review Status: โœ… Complete

Next Review: When major changes occur