@extends('index') @section('content')

Process Travel Card Details

@if($ptc->stock_status == 6) @endif Back
PTC No: PTC-{{ $ptc->stock_no }}
Date: {{ \carbon\Carbon::parse($ptc->stock_date)->format('d-m-Y') }}
Order: {{ $ptc->job_no ?? 'Default PTC' }}
Status: @if($ptc->stock_status == 6) In Progress @elseif($ptc->stock_status == 7) Completed @endif
Product: {{ $product ? $product->name . ' - ' . $product->size_name : 'N/A' }}
Order Qty: {{ $orderQuantity ?? 'N/A' }}
@php // Extract quantity from description [QTY:X] format $ptcQty = 1; if (preg_match('/\[QTY:(\d+)\]/', $ptc->description ?? '', $matches)) { $ptcQty = $matches[1]; } @endphp PTC Qty: {{ $ptcQty }}
Current Stage: {{ $ptc->current_stage_name ?? 'Completed' }}
@foreach($stages as $index => $stage) @php $isCompleted = false; $isCurrent = false; if ($ptc->stock_status == 7) { $isCompleted = true; } elseif ($ptc->current_stage_id == $stage->head_id) { $isCurrent = true; } else { // Check if this stage comes before current stage $currentIndex = collect($stages)->search(fn($s) => $s->head_id == $ptc->current_stage_id); $isCompleted = $index < $currentIndex; } @endphp
@if($isCompleted) @endif {{ $index + 1 }}. {{ $stage->name }}
@if($index < count($stages) - 1)
@endif @endforeach
@php // Remove [QTY:X] from description for display $cleanDescription = preg_replace('/\s*\[QTY:\d+\]/', '', $ptc->description ?? ''); $cleanDescription = trim($cleanDescription); @endphp @if($cleanDescription)
Description
{!! $cleanDescription !!}
@endif
Issuance Records @if($ptc->stock_status == 6) New Issuance @endif
@forelse($issuances as $index => $issuance) @php $relatedReceivings = $receivingsByIssueId[$issuance->stock_id] ?? collect(); $isReceived = $relatedReceivings->count() > 0; // Format issuance number: I + padded sequence $issuanceSeqNo = str_pad($index + 1, 3, '0', STR_PAD_LEFT); @endphp @empty @endforelse
Sr. Issuance Reference For Stage Date Issued To Status Actions
{{ $index + 1 }} PTC-{{ $ptc->stock_no }} / I{{ $issuanceSeqNo }} @if($issuance->is_ptc_master == 1) Initial @endif {{ $issuance->stage_name ?? 'N/A' }} {{ \carbon\Carbon::parse($issuance->stock_date)->format('d-m-Y') }} {{ $issuance->employee_name ?? $issuance->vendor_name ?? '-' }} @if($isReceived) Received ({{ $relatedReceivings->count() }}) @else Not Received @endif @if($isReceived) @endif @if($ptc->stock_status == 6) Add Receiving @endif @if(!$isReceived) {{-- Edit button only visible for issuances that have NOT been received yet --}} @if($issuance->is_ptc_master == 1) Edit @else Edit @endif @endif
No issuance records yet.
@if($movements && $movements->count() > 0)
Complete Movement History
@php // Build a map of issuance stock_ids to their sequence numbers $issuanceSeqMap = []; foreach($issuances as $idx => $iss) { $issuanceSeqMap[$iss->stock_id] = str_pad($idx + 1, 3, '0', STR_PAD_LEFT); } @endphp @foreach($movements as $index => $movement) @php // Format display reference based on type if ($movement->is_ptc_master == 1) { $displayRef = 'PTC-' . $ptc->stock_no . ' / I001'; } elseif ($movement->stock_type == 2) { // Issuance - find sequence from map $issSeq = $issuanceSeqMap[$movement->stock_id] ?? $movement->stock_no; $displayRef = 'PTC-' . $ptc->stock_no . ' / I' . $issSeq; } else { // Receiving - use stored format directly (R{n}-I{seq}) $displayRef = 'PTC-' . $ptc->stock_no . ' / ' . $movement->stock_no; } @endphp @endforeach
Sr. Reference Type Stage Date By Actions
{{ $index + 1 }} {{ $displayRef }} @if($movement->is_ptc_master == 1) Initial Issue @elseif($movement->stock_type == 1) Receive @else Issue @endif @if($movement->stock_type == 1) {{ $movement->stage_name ?? 'N/A' }} @else {{ $movement->issue_stage_name ?? $movement->stage_name ?? 'N/A' }} @endif {{ \carbon\Carbon::parse($movement->stock_date)->format('d-m-Y') }} {{ $movement->employee_name ?? $movement->vendor_name ?? '-' }}
@endif
@if($movements && $movements->count() > 0) @php // Build maps for modal display $modalIssuanceSeqMap = []; foreach($issuances as $idx => $iss) { $modalIssuanceSeqMap[$iss->stock_id] = str_pad($idx + 1, 3, '0', STR_PAD_LEFT); } @endphp @foreach($movements as $movement) @php // Format display reference for modal if ($movement->is_ptc_master == 1) { $modalDisplayRef = 'PTC-' . $ptc->stock_no . ' / I001'; } elseif ($movement->stock_type == 2) { $issSeq = $modalIssuanceSeqMap[$movement->stock_id] ?? $movement->stock_no; $modalDisplayRef = 'PTC-' . $ptc->stock_no . ' / I' . $issSeq; } else { // Receiving - use stored format directly (R{n}-I{seq}) $modalDisplayRef = 'PTC-' . $ptc->stock_no . ' / ' . $movement->stock_no; } @endphp @endforeach @endif @foreach($issuances as $issIdx => $issuance) @php $relatedReceivings = $receivingsByIssueId[$issuance->stock_id] ?? collect(); $issuanceSeqNoForModal = str_pad($issIdx + 1, 3, '0', STR_PAD_LEFT); @endphp @if($relatedReceivings->count() > 0) @endif @endforeach @endsection