Merge pull request 'changed month logic in pallet print' (#813) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 23s

Reviewed-on: #813
This commit was merged in pull request #813.
This commit is contained in:
2026-07-07 03:52:46 +00:00

View File

@@ -163,8 +163,6 @@ class PalletPrintController extends Controller
public function print(Request $request, $pallet, $plant) public function print(Request $request, $pallet, $plant)
{ {
// $customerPo = $request->query('customer');
$customerPoMasterId = WireMasterPacking::where('plant_id', $plant) $customerPoMasterId = WireMasterPacking::where('plant_id', $plant)
->where('wire_packing_number', $pallet) ->where('wire_packing_number', $pallet)
->value('customer_po_master_id'); ->value('customer_po_master_id');
@@ -187,15 +185,15 @@ class PalletPrintController extends Controller
$customerCode = $customer->customer_po ?? ''; $customerCode = $customer->customer_po ?? '';
$customerName = $customer->customer_name ?? ''; $customerName = $customer->customer_name ?? '';
$totalBoxes = WireMasterPacking::where('plant_id', $plant) $totalBoxes = WireMasterPacking::where('plant_id', $plant)
->where('customer_po_master_id', $customerPoMasterId) ->where('customer_po_master_id', $customerPoMasterId)
->select('wire_packing_number') ->select('wire_packing_number')
->groupBy('wire_packing_number') ->groupBy('wire_packing_number')
->havingRaw( ->havingRaw(
'COUNT(*) = COUNT(CASE WHEN wire_packing_status = ? THEN 1 END)', 'COUNT(*) = COUNT(CASE WHEN wire_packing_status = ? THEN 1 END)',
['Completed'] ['Completed']
) )
->count(); ->count();
$completedPallets = WireMasterPacking::where('plant_id', $plant) $completedPallets = WireMasterPacking::where('plant_id', $plant)
->where('customer_po_master_id', $customerPoMasterId) ->where('customer_po_master_id', $customerPoMasterId)
@@ -211,7 +209,7 @@ class PalletPrintController extends Controller
$index = $completedPallets->search($pallet); $index = $completedPallets->search($pallet);
$currentPalletNo = ($index !== false) ? $index + 1 : 1; $currentPalletNo = ($index !== false) ? $index + 1 : 0;
$boxLabel = $currentPalletNo.'/'.$totalBoxes; $boxLabel = $currentPalletNo.'/'.$totalBoxes;
@@ -223,11 +221,18 @@ class PalletPrintController extends Controller
$plantAddress = Plant::where('id', $plant)->value('address'); $plantAddress = Plant::where('id', $plant)->value('address');
$scannedAt = WireMasterPacking::where('plant_id', $plant)
->where('wire_packing_number', $pallet)
->value('scanned_at');
$pdf = Pdf::loadView('pdf.wire-pallet', [ $pdf = Pdf::loadView('pdf.wire-pallet', [
'product' => 'Submersible Winding Wire', 'product' => 'Submersible Winding Wire',
'plantName' => $plantName, 'plantName' => $plantName,
'plantAddress' => $plantAddress, 'plantAddress' => $plantAddress,
'monthYear' => now()->format('M-y'), // 'monthYear' => now()->format('M-y'),
'monthYear' => $scannedAt
? \Carbon\Carbon::parse($scannedAt)->format('M-y')
: '',
'branch' => '', 'branch' => '',
'customerCode' => $customerCode, 'customerCode' => $customerCode,
'customerName' => $customerName, 'customerName' => $customerName,