changed month logic in pallet print #813

Merged
jothi merged 1 commits from ranjith-dev into master 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)
{
// $customerPo = $request->query('customer');
$customerPoMasterId = WireMasterPacking::where('plant_id', $plant)
->where('wire_packing_number', $pallet)
->value('customer_po_master_id');
@@ -187,15 +185,15 @@ class PalletPrintController extends Controller
$customerCode = $customer->customer_po ?? '';
$customerName = $customer->customer_name ?? '';
$totalBoxes = WireMasterPacking::where('plant_id', $plant)
->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']
)
->count();
$totalBoxes = WireMasterPacking::where('plant_id', $plant)
->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']
)
->count();
$completedPallets = WireMasterPacking::where('plant_id', $plant)
->where('customer_po_master_id', $customerPoMasterId)
@@ -211,7 +209,7 @@ class PalletPrintController extends Controller
$index = $completedPallets->search($pallet);
$currentPalletNo = ($index !== false) ? $index + 1 : 1;
$currentPalletNo = ($index !== false) ? $index + 1 : 0;
$boxLabel = $currentPalletNo.'/'.$totalBoxes;
@@ -223,11 +221,18 @@ class PalletPrintController extends Controller
$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', [
'product' => 'Submersible Winding Wire',
'plantName' => $plantName,
'plantAddress' => $plantAddress,
'monthYear' => now()->format('M-y'),
// 'monthYear' => now()->format('M-y'),
'monthYear' => $scannedAt
? \Carbon\Carbon::parse($scannedAt)->format('M-y')
: '',
'branch' => '',
'customerCode' => $customerCode,
'customerName' => $customerName,