corrected logic in wire print page
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 1m14s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 59s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 1m33s
Laravel Pint / pint (pull_request) Successful in 2m11s
Laravel Larastan / larastan (pull_request) Failing after 4m20s

This commit is contained in:
dhanabalan
2026-07-06 11:50:46 +05:30
parent faa355ad79
commit 0d6ced5f63
2 changed files with 220 additions and 216 deletions

View File

@@ -15,6 +15,7 @@ use Filament\Forms\Components\Section;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Notifications\Notification;
use Illuminate\Support\Facades\Log;
class WireMasterPrint extends Page
{
@@ -77,41 +78,66 @@ class WireMasterPrint extends Page
return [];
}
return CustomerPoMaster::where('plant_id', $plantId)->pluck('customer_po', 'id');
return CustomerPoMaster::where('plant_id', $plantId)->distinct()->pluck('customer_po', 'customer_po'); //->pluck('customer_po', 'id'); ->distinct()
})
->required(),
select::make('scan_pallet_no')
Select::make('scan_pallet_no')
->label('Scan Pallet No')
->reactive()
->searchable()
->options(function ($get) {
$plantId = $get('plant_id');
$customerPoId = $get('customer_po_master_id');
// $plantId = $get('plant_id');
// $customerPoId = $get('customer_po_master_id');
if (! $plantId || ! $customerPoId) {
// if (! $plantId || ! $customerPoId) {
// return [];
// }
// $palletNumbers = WireMasterPacking::query()
// ->select('wire_packing_number')
// ->where('plant_id', $plantId)
// ->where('customer_po_master_id', $customerPoId)
// ->whereNotNull('wire_packing_number')
// ->groupBy('wire_packing_number')
// ->havingRaw('COUNT(*) = COUNT(wire_packing_status)')
// ->havingRaw("SUM(CASE WHEN TRIM(wire_packing_status) = '' THEN 1 ELSE 0 END) = 0")
// ->orderBy('wire_packing_number', 'asc')
// ->pluck('wire_packing_number')
// ->toArray();
// return collect($palletNumbers)
// ->mapWithKeys(fn ($number) => [$number => $number])
// ->toArray();
//..New Logic
$plantId = $get('plant_id');
$customerPo = $get('customer_po_master_id');
if (! $plantId || ! $customerPo)
{
return [];
}
$poIds = CustomerPoMaster::where('plant_id', $plantId)->where('customer_po', $customerPo)->pluck('id');
$palletNumbers = WireMasterPacking::query()
->select('wire_packing_number')
->where('plant_id', $plantId)
->where('customer_po_master_id', $customerPoId)
->whereIn('customer_po_master_id', $poIds)
->whereNotNull('wire_packing_number')
->groupBy('wire_packing_number')
->havingRaw('COUNT(*) = COUNT(wire_packing_status)')
->havingRaw("SUM(CASE WHEN TRIM(wire_packing_status) = '' THEN 1 ELSE 0 END) = 0")
->orderBy('wire_packing_number', 'asc')
->orderBy('wire_packing_number')
->pluck('wire_packing_number')
->toArray();
return collect($palletNumbers)
->mapWithKeys(fn ($number) => [$number => $number])
->toArray();
return collect($palletNumbers) ->mapWithKeys(fn ($number) => [$number => $number]) ->toArray();
})
->afterStateUpdated(function ($state, callable $set, $get) {
$palletNo = $state;
$plantId = $get('plant_id');
$this->dispatch('loadData', $palletNo, $plantId);
})
->extraAttributes([