diff --git a/app/Controllers/ExcelExportController.php b/app/Controllers/ExcelExportController.php index c55ff89..7b6eec4 100644 --- a/app/Controllers/ExcelExportController.php +++ b/app/Controllers/ExcelExportController.php @@ -1557,13 +1557,23 @@ class ExcelExportController extends ResourceController $serialNo = 1; $totalSum = 0; + // foreach ($data as $row) { + // $indexedRow = array_values($row); + // $lastIndex = count($indexedRow) - 1; + // $totalSum += (float) $indexedRow[$lastIndex]; + // unset($indexedRow[$lastIndex]); + // $finalData[] = array_merge([$serialNo++], $indexedRow); + // } + foreach ($data as $row) { + $indexedRow = array_values($row); - - $totalSum += (float) $row['commission_amount']; - // $lastIndex = count($indexedRow) - 1; - // $totalSum += (float) $indexedRow[$lastIndex]; - // unset($indexedRow[$lastIndex]); + + // Commission Amount is last column + $commissionIndex = count($indexedRow) - 1; + + $totalSum += (float) $indexedRow[$commissionIndex]; + $finalData[] = array_merge([$serialNo++], $indexedRow); }