Changed logic in production target plan #1134
@@ -20,7 +20,7 @@ class ProductionTargetPlan extends Component
|
||||
|
||||
public $dates = [];
|
||||
|
||||
public $monthlyRecords;
|
||||
public $monthlyRecords = [];
|
||||
|
||||
public $leaveDates = [];
|
||||
|
||||
@@ -629,16 +629,11 @@ class ProductionTargetPlan extends Component
|
||||
}
|
||||
|
||||
public function loadMonthlyPlan($year, $month, $plantId, $lineId){
|
||||
$this->monthlyRecords = ProductionPlan::query()
|
||||
->selectRaw('
|
||||
plant_id,
|
||||
line_id,
|
||||
SUM(plan_quantity) as monthly_plan
|
||||
')
|
||||
return ProductionPlan::where('plant_id', $plantId)
|
||||
->where('line_id', $lineId)
|
||||
->whereYear('created_at', $year)
|
||||
->whereMonth('created_at', $month)
|
||||
->groupBy('plant_id', 'line_id')
|
||||
->get();
|
||||
->sum('plan_quantity');
|
||||
}
|
||||
|
||||
|
||||
@@ -655,6 +650,7 @@ class ProductionTargetPlan extends Component
|
||||
// return view('livewire.production-target-plan');
|
||||
return view('livewire.production-target-plan', [
|
||||
'records' => $this->records,
|
||||
'monthlyRecords' => $this->monthlyRecords,
|
||||
'dates' => $this->dates,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
</thead>
|
||||
|
||||
<tbody class="divide-y divide-gray-100">
|
||||
@forelse ($records as $index => $record)
|
||||
@forelse ($monthlyRecords as $index => $record)
|
||||
<tr class="hover:bg-gray-50">
|
||||
|
||||
<td class="border px-4 py-2">
|
||||
|
||||
Reference in New Issue
Block a user