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 @@ + +
- +
- - - - - - + + $distinctMaterialCode){ ?> + + + + - + + $distinctMaterialCode){ ?> - - - + + + - - - - - - - - - - - - - - - - - - + + $distinctMaterialCode){ ?> + + + + + + + + + + - - - - - - - - - - + $bagStockDetails){ + ?> - - - - - - - - + + $bagStockDetail){ ?> + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - +
material material 1material 2material material
Customer Customer - + + -
Date Date material customerOpeningReceiptUsedBalance StockDate material customerOpeningReceiptUsedBalance StockDate OpeningReceiptUsedBalance Stock
23-10-202423-10-2024 material 1 customer 147211212-47223-10-2024 material 2 customer 247211212-472
24-10-202424-10-2024 material 1 customer 147211212-47224-10-2024 material 2 customer 247211212-472