diff --git a/app/Livewire/SelectPlant.php b/app/Livewire/SelectPlant.php
new file mode 100644
index 000000000..e1a807522
--- /dev/null
+++ b/app/Livewire/SelectPlant.php
@@ -0,0 +1,82 @@
+ 'updatePlantLine',
+ 'productionUpdated' => '$refresh'
+ ];
+
+ public $plantId;
+ public $lineId;
+
+ public $hourlyData = [];
+
+ public function updatePlantLine($plantId, $lineId)
+ {
+ session(['plantId' => $plantId, 'lineId' => $lineId]);
+ $this->plantId = $plantId;
+ $this->lineId = $lineId;
+ $this->loadData();
+ }
+
+ // Method to load hourly production data
+ public function loadData()
+ {
+ // Define the time range from today 8:00 AM to the next day 8:00 AM
+ $today = now()->startOfDay()->addHours(8); // Today 8:00 AM
+ $nextDay = $today->copy()->addDay(); // Next day 8:00 AM
+
+ // Initialize the array to hold the hourly data
+ $productionCounts = [];
+
+ // Loop through each hour from today 8:00 AM to the next day 8:00 AM
+ for ($i = 0; $i < 24; $i++) {
+ // Define the start and end time for the current hour
+ $startOfHour = $today->copy()->addHours($i); // Start of the hour
+ $endOfHour = $startOfHour->copy()->addHour()->subSeconds(1); // End of the hour
+
+ // Query the production counts for the current hour (between start and end time)
+ $count = ProductionQuantity::query()
+ ->where('plant_id', $this->plantId)
+ ->where('line_id', $this->lineId)
+ ->whereBetween('created_at', [$startOfHour, $endOfHour])
+ ->count(); // Count the number of records in the current hour
+
+ // Store the count for the current hour in the production counts array
+ $productionCounts[$i] = $count;
+
+ }
+
+ // Set the hourly data to be used in the component's view
+ $this->hourlyData = $productionCounts;
+
+ }
+
+ // public function render()
+ // {
+ // return view('livewire.select-plant', [
+ // 'hourlyData' => $this->hourlyData,
+ // ]);
+ // }
+
+ public function mount()
+ {
+ $this->plantId = session('plantId');
+ $this->lineId = session('lineId');
+
+ if ($this->plantId && $this->lineId) {
+ $this->loadData();
+ }
+ }
+
+}
diff --git a/resources/views/livewire/select-plant.blade.php b/resources/views/livewire/select-plant.blade.php
new file mode 100644
index 000000000..8d5ab9520
--- /dev/null
+++ b/resources/views/livewire/select-plant.blade.php
@@ -0,0 +1,170 @@
+
+
+
+
+
+
+
+
+
+ | No |
+ Time Range |
+ Production Quantity |
+
+
+
+ @php
+ // Static time range for the first 12 hours (08:00 AM to 07:00 PM)
+ $timeRanges = [
+ '08:00 AM - 09:00 AM',
+ '09:00 AM - 10:00 AM',
+ '10:00 AM - 11:00 AM',
+ '11:00 AM - 12:00 PM',
+ '12:00 PM - 13:00 PM',
+ '13:00 PM - 14:00 PM',
+ '14:00 PM - 15:00 PM',
+ '15:00 PM - 16:00 PM',
+ '16:00 PM - 17:00 PM',
+ '17:00 PM - 18:00 PM',
+ '18:00 PM - 19:00 PM',
+ '19:00 PM - 20:00 PM',
+ ];
+ @endphp
+
+ @foreach ($timeRanges as $index => $timeRange)
+
+ | {{ $index + 1 }} |
+ {{ $timeRange }} |
+
+ {{ $hourlyData[$index] ?? 0 }}
+ |
+
+ @endforeach
+
+
+
+
+
+
+
+
+ | No |
+ Time Range |
+ Production Quantity |
+
+
+
+ @php
+ // Static time range for the first 12 hours (08:00 AM to 07:00 PM)
+ $timeRanges = [
+ '20:00 PM - 21:00 PM',
+ '21:00 PM - 22:00 PM',
+ '22:00 PM - 23:00 PM',
+ '23:00 PM - 12:00 AM',
+ '12:00 AM - 01:00 AM',
+ '01:00 AM - 02:00 AM',
+ '02:00 AM - 03:00 AM',
+ '03:00 AM - 04:00 AM',
+ '04:00 AM - 05:00 AM',
+ '05:00 AM - 06:00 AM',
+ '06:00 AM - 07:00 AM',
+ '07:00 AM - 08:00 AM',
+ ];
+ @endphp
+
+ @foreach ($timeRanges as $index => $timeRange)
+
+ | {{ $index + 13 }} |
+ {{ $timeRange }} |
+
+ {{ $hourlyData[$index + 12] ?? 0 }}
+ |
+
+ @endforeach
+
+
+
+
+
+ {{--
+
+
+
+ | No |
+ Time Range |
+ Production Quantity |
+
+
+
+ | 13 | 08:00 PM - 09:00 PM | {{ $productionQuantities[12] }} |
+ | 14 | 09:00 PM - 10:00 PM | {{ $productionQuantities[13] }} |
+ | 15 | 10:00 PM - 11:00 PM | {{ $productionQuantities[14] }} |
+ | 16 | 11:00 PM - 12:00 AM | {{ $productionQuantities[15] }} |
+ | 17 | 12:00 AM - 01:00 AM | {{ $productionQuantities[16] }} |
+ | 18 | 01:00 AM - 02:00 AM | {{ $productionQuantities[17] }} |
+ | 19 | 02:00 AM - 03:00 AM | {{ $productionQuantities[18] }} |
+ | 20 | 03:00 AM - 04:00 AM | {{ $productionQuantities[19] }} |
+ | 21 | 04:00 AM - 05:00 AM | {{ $productionQuantities[20] }} |
+ | 22 | 05:00 AM - 06:00 AM | {{ $productionQuantities[21] }} |
+ | 23 | 06:00 AM - 07:00 AM | {{ $productionQuantities[22] }} |
+ | 24 | 07:00 AM - 08:00 AM | {{ $productionQuantities[23] }} |
+
+
+
--}}
+
+
+
+{{-- //..perfect logic --}}
+
+{{--
+
+
+
+
+
+ | No |
+ Time Range |
+ Production Quantity |
+
+
+
+ @foreach ($hourlyData as $index => $data)
+ @if ($index < 12)
+
+ | {{ $index + 1 }} |
+ {{ $data['time'] }} |
+ {{ $data['quantity'] ?: '0' }} |
+
+ @endif
+ @endforeach
+
+
+
+
+
+
+
+
+
+ | No |
+ Time Range |
+ Production Quantity |
+
+
+
+ @foreach ($hourlyData as $index => $data)
+ @if ($index >= 12)
+
+ | {{ $index + 1 }} |
+ {{ $data['time'] }} |
+ {{ $data['quantity'] ?: '0' }} |
+
+ @endif
+ @endforeach
+
+
+
+
--}}
+
+
+