Added plant and line in non production plan grid
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 21s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 17s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 13s
Laravel Pint / pint (pull_request) Successful in 3m50s
Laravel Larastan / larastan (pull_request) Failing after 4m18s
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 21s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 17s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 13s
Laravel Pint / pint (pull_request) Successful in 3m50s
Laravel Larastan / larastan (pull_request) Failing after 4m18s
This commit is contained in:
@@ -2,11 +2,13 @@
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Exports\ProductionNonPlanExport;
|
||||
use App\Models\ProductionPlan;
|
||||
use App\Models\QualityValidation;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Livewire\Component;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
|
||||
class ProductionNonPlanned extends Component
|
||||
{
|
||||
@@ -20,8 +22,6 @@ class ProductionNonPlanned extends Component
|
||||
|
||||
public int $nonPlannedQuantity = 0;
|
||||
|
||||
// public $dates = [];
|
||||
|
||||
public $monthlyRecords = [];
|
||||
|
||||
public $efficiency = [];
|
||||
@@ -37,7 +37,8 @@ class ProductionNonPlanned extends Component
|
||||
|
||||
protected $listeners = [
|
||||
'loadData' => 'loadProductionData',
|
||||
'loadDataCategory' => 'loadProductionCategoryData'
|
||||
'loadDataCategory' => 'loadProductionCategoryData',
|
||||
'loadDataExport' => 'exportNonPlannedData'
|
||||
];
|
||||
|
||||
public function loadProductionData($date, $plantId, $lineId)
|
||||
@@ -116,6 +117,18 @@ class ProductionNonPlanned extends Component
|
||||
'=',
|
||||
'sticker_masters.item_id'
|
||||
)
|
||||
->join(
|
||||
'plants',
|
||||
'plants.id',
|
||||
'=',
|
||||
'quality_validations.plant_id'
|
||||
)
|
||||
->join(
|
||||
'lines',
|
||||
'lines.id',
|
||||
'=',
|
||||
'quality_validations.line_id'
|
||||
)
|
||||
->where('quality_validations.plant_id', $plantId)
|
||||
->where('quality_validations.line_id', $lineId)
|
||||
->where('quality_validations.created_at', '>=', $startDate)
|
||||
@@ -130,6 +143,8 @@ class ProductionNonPlanned extends Component
|
||||
|
||||
$nonPlannedData = $nonPlannedQuery
|
||||
->selectRaw("
|
||||
plants.name as plant_name,
|
||||
lines.name as line_name,
|
||||
sticker_masters.item_id,
|
||||
items.code as item_code,
|
||||
items.description as item_description,
|
||||
@@ -137,6 +152,8 @@ class ProductionNonPlanned extends Component
|
||||
COUNT(*) as total_qty
|
||||
")
|
||||
->groupBy(
|
||||
'plants.name',
|
||||
'lines.name',
|
||||
'sticker_masters.item_id',
|
||||
'items.code',
|
||||
'items.description',
|
||||
@@ -228,6 +245,18 @@ class ProductionNonPlanned extends Component
|
||||
'=',
|
||||
'sticker_masters.item_id'
|
||||
)
|
||||
->join(
|
||||
'plants',
|
||||
'plants.id',
|
||||
'=',
|
||||
'quality_validations.plant_id'
|
||||
)
|
||||
->join(
|
||||
'lines',
|
||||
'lines.id',
|
||||
'=',
|
||||
'quality_validations.line_id'
|
||||
)
|
||||
->where('quality_validations.plant_id', $plantId)
|
||||
->where('quality_validations.line_id', $lineId)
|
||||
->where('items.category', $category)
|
||||
@@ -243,6 +272,8 @@ class ProductionNonPlanned extends Component
|
||||
|
||||
$nonPlannedData = $nonPlannedQuery
|
||||
->selectRaw("
|
||||
plants.name as plant_name,
|
||||
lines.name as line_name,
|
||||
sticker_masters.item_id,
|
||||
items.code as item_code,
|
||||
items.description as item_description,
|
||||
@@ -250,6 +281,8 @@ class ProductionNonPlanned extends Component
|
||||
COUNT(*) as total_qty
|
||||
")
|
||||
->groupBy(
|
||||
'plants.name',
|
||||
'lines.name',
|
||||
'sticker_masters.item_id',
|
||||
'items.code',
|
||||
'items.description',
|
||||
@@ -264,15 +297,24 @@ class ProductionNonPlanned extends Component
|
||||
$this->nonPlannedQuantity = (int) $nonPlannedData->sum('total_qty');
|
||||
}
|
||||
|
||||
public function exportNonPlannedData()
|
||||
{
|
||||
$selectedDate = Carbon::parse($this->date)->toDateString();
|
||||
|
||||
$startDate = Carbon::parse($selectedDate)->setTime(8, 0, 0);
|
||||
$endDate = $startDate->copy()->addDay();
|
||||
return Excel::download(
|
||||
new ProductionNonPlanExport($this->nonPlannedRecords, $startDate->toDateTimeString(),
|
||||
$endDate->toDateTimeString()),
|
||||
'production_non_plan_data.xlsx'
|
||||
);
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
// return view('livewire.production-non-planned');
|
||||
return view('livewire.production-non-planned', [
|
||||
'records' => $this->records,
|
||||
'monthlyRecords' => $this->monthlyRecords,
|
||||
'monthlyActualRecords' => $this->monthlyActualQuantity,
|
||||
'monthlyEfficiency' => $this->efficiency,
|
||||
'dates' => $this->dates,
|
||||
'records' => $this->nonPlannedRecords,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
<thead class="bg-gray-100 text-sm font-semibold uppercase text-gray-700">
|
||||
<tr>
|
||||
<th class="border px-4 py-2">No</th>
|
||||
<th class="border px-4 py-2">Plant</th>
|
||||
<th class="border px-4 py-2">Line</th>
|
||||
<th class="border px-4 py-2">Item Code</th>
|
||||
<th class="border px-4 py-2">Category</th>
|
||||
<th class="border px-4 py-2">Non Planned Quantity</th>
|
||||
@@ -18,6 +20,8 @@
|
||||
@foreach ($nonPlannedRecords as $index => $item)
|
||||
<tr>
|
||||
<td class="border px-4 py-2">{{ $index + 1 }}</td>
|
||||
<td class="border px-4 py-2">{{ $item['plant_name'] }}</td>
|
||||
<td class="border px-4 py-2">{{ $item['line_name'] }}</td>
|
||||
<td class="border px-4 py-2">{{ $item['item_code'] }}</td>
|
||||
<td class="border px-4 py-2">{{ $item['item_category'] }}</td>
|
||||
<td class="border px-4 py-2">{{ $item['total_qty'] }}</td>
|
||||
|
||||
Reference in New Issue
Block a user