diff --git a/app/Controllers/StockController.php b/app/Controllers/StockController.php index 0728316c..31739345 100644 --- a/app/Controllers/StockController.php +++ b/app/Controllers/StockController.php @@ -285,9 +285,37 @@ class StockController extends BaseController ->where('date >=', $startDate) ->where('date <=', $endDate) ->groupBy(['materialCode','date']) - ->orderBy('date','desc') + ->orderBy('date','asc') + ->orderBy('materialCode','asc') ->findAll(); + // Initialize an empty array to hold the grouped data + $data['groupedBagStockDetails'] = []; + + // Temporary array to store grouped data by date + $groupedByDate = []; + + // Group by 'date' + foreach ($data['bagStockDetails'] as $detail) { + $date = $detail['date']; + + // Initialize the array for this date if it doesn't exist + if (!isset($groupedByDate[$date])) { + $groupedByDate[$date] = []; + } + + // Append the detail to the sub-array for this date + $groupedByDate[$date][] = $detail; + } + + // Reset the structure to have indexed arrays without the date keys + $data['groupedBagStockDetails'] = array_values($groupedByDate); + + $data['distinctMaterialCodes'] = $this->bagStockDetails_model + ->distinct() + ->select('materialCode') + ->findAll(); + $date = DateTime::createFromFormat('Y-m', $month); $formattedDate = $date->format('M-Y'); diff --git a/app/Views/bagStockDetails.php b/app/Views/bagStockDetails.php index 7d09ddb5..d95514c5 100644 --- a/app/Views/bagStockDetails.php +++ b/app/Views/bagStockDetails.php @@ -205,104 +205,84 @@ + +
| material | - - -material 1 | - -material 2 | +material | + $distinctMaterialCode){ ?> + +material | +|||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Customer | +Customer | + $distinctMaterialCode){ ?> -- + | + | -- | - + +|||||||||
| Date | - - - - - -Opening | -Receipt | -Used | -Balance Stock | - - - - -Opening | -Receipt | -Used | -Balance Stock | +Date | + $distinctMaterialCode){ ?> + + + + +Opening | +Receipt | +Used | +Balance Stock | +
| 23-10-2024 | - - - -472 | -11212 | -- | -472 | + $bagStockDetails){ + ?> - - - -472 | -11212 | -- | -472 | - +|||||
| = $bagStockDetail['date'] ?> | + + + + += $bagStockDetail['opening']?> | += $bagStockDetail['receipt']?> | += $bagStockDetail['used']?> | += $bagStockDetail['balanceStock']?> | + +|||||||||
| 24-10-2024 | - - - -472 | -11212 | -- | -472 | - - - - -472 | -11212 | -- | -472 | - - -|||||