diff --git a/app/Http/Controllers/PalletPrintController.php b/app/Http/Controllers/PalletPrintController.php index 72baafc..3dfa365 100644 --- a/app/Http/Controllers/PalletPrintController.php +++ b/app/Http/Controllers/PalletPrintController.php @@ -163,11 +163,6 @@ class PalletPrintController extends Controller public function print(Request $request, $pallet, $plant) { - $customerPo = WireMasterPacking::where('plant_id', $plant) - ->where('wire_packing_number', $pallet) - // ->value('customer_po_master_id'); - ->value('customer_po'); - $customerPoMasterId = WireMasterPacking::where('plant_id', $plant) ->where('wire_packing_number', $pallet) ->value('customer_po_master_id'); @@ -191,8 +186,7 @@ class PalletPrintController extends Controller $customerName = $customer->customer_name ?? ''; $totalBoxes = WireMasterPacking::where('plant_id', $plant) - // ->where('customer_po_master_id', $customerPoMasterId) - ->where('customer_po', $customerPo) + ->where('customer_po_master_id', $customerPoMasterId) ->select('wire_packing_number') ->groupBy('wire_packing_number') ->havingRaw( @@ -201,29 +195,17 @@ class PalletPrintController extends Controller ) ->count(); - // $completedPallets = WireMasterPacking::where('plant_id', $plant) - // ->where('customer_po_master_id', $customerPo) - // ->select('wire_packing_number') - // ->groupBy('wire_packing_number') - // ->havingRaw( - // 'COUNT(*) = COUNT(CASE WHEN wire_packing_status = ? THEN 1 END)', - // ['Completed'] - // ) - // ->orderBy('wire_packing_number') - // ->pluck('wire_packing_number') - // ->values(); - $completedPallets = WireMasterPacking::where('plant_id', $plant) - ->where('customer_po', $customerPo) - ->select('wire_packing_number') - ->groupBy('wire_packing_number') - ->havingRaw( - 'COUNT(*) = COUNT(CASE WHEN wire_packing_status = ? THEN 1 END)', - ['Completed'] - ) - ->orderBy('wire_packing_number') - ->pluck('wire_packing_number') - ->values(); + ->where('customer_po_master_id', $customerPoMasterId) + ->select('wire_packing_number') + ->groupBy('wire_packing_number') + ->havingRaw( + 'COUNT(*) = COUNT(CASE WHEN wire_packing_status = ? THEN 1 END)', + ['Completed'] + ) + ->orderBy('wire_packing_number') + ->pluck('wire_packing_number') + ->values(); $index = $completedPallets->search($pallet);