@extends('layouts.app') @section('content')
{{-- Quick Info Cards --}}
Current Approver
@php $approver = $request->currentApprover ?? null; if (!$approver && !empty($request->current_approver_id)) { $approver = \App\Models\User::find($request->current_approver_id); } @endphp @if($approver) {{ $approver->name }}
{{ $approver->designation ?? $approver->role ?? '' }} @else None assigned @endif
Current Status
@if($request->status == 'pending') Pending Review @elseif($request->status == 'approved') Approved @elseif($request->status == 'completed') Completed @elseif($request->status == 'rejected') Rejected @elseif($request->status == 'rejected_resubmit') Pending Resubmission @elseif($request->status == 'resubmitted') Resubmitted - Pending Review @elseif($request->status == 'escalated') Approve & Escalated @else {{ ucfirst($request->status) }} @endif @if(in_array($request->status, ['approved', 'completed'])) @endif
Created
@if($request->created_at) {{ $request->created_at->setTimezone('Asia/Kuala_Lumpur')->format('d/m/Y H:i') }}
{{ $request->created_at->setTimezone('Asia/Kuala_Lumpur')->diffForHumans() }} @else Unknown @endif
Submitted By
{{ $request->submitter ? $request->submitter->name : 'Unknown' }} @if($request->submitter && $request->submitter->designation)
{{ $request->submitter->designation }} @endif
{{ $request->title }}

Created By: {{ $request->submitter ? $request->submitter->name : '-' }}

Created At: @if($request->created_at) {{ $request->created_at->setTimezone('Asia/Kuala_Lumpur')->format('d/m/Y H:i') }} ({{ $request->created_at->setTimezone('Asia/Kuala_Lumpur')->diffForHumans() }}) @else - @endif

Status: @if($request->status == 'rejected') Rejected @elseif($request->status == 'completed') Completed @elseif($request->status == 'escalated') Approved & Escalated @elseif($request->status == 'approved') Approved @else {{ ucfirst($request->status) }} @endif


Category: {{ $request->category }}

@if($request->category == 'Other' && !empty($request->other_category))

Other Category: {{ $request->other_category }}

@endif

Purchase Request Type: {{ $request->request_type }}

@if(!empty($request->project_name))

Project Name: {{ $request->project_name }}

@endif @if($request->request_type)

Approval Workflow:

{{ $request->getWorkflowDescription() }}
@endif

Branch: {{ ucfirst($request->branch) }}

@if(!empty($request->unit))

Unit: {{ $request->unit }}

@endif

Urgency: @if($request->urgency == 'High') High @elseif($request->urgency == 'Medium') Medium @elseif($request->urgency == 'Low') Low @else {{ $request->urgency }} @endif

Description / Justification:

{{ $request->description }}
@if(!empty($request->attachments))
General Attachments
    @php $attachments = []; if (!empty($request->attachments)) { if (is_array($request->attachments)) { $attachments = $request->attachments; } elseif (is_string($request->attachments)) { $decoded = json_decode($request->attachments, true); $attachments = is_array($decoded) ? $decoded : []; } } @endphp @forelse($attachments as $file)
  • {{ $file['original'] ?? 'Attachment' }}
  • @empty
  • No attachments available
  • @endforelse
@endif

Approval Workflow & History

Complete timeline of all actions taken on this request
@foreach($request->approvals()->orderBy('created_at', 'asc')->get() as $approval) @endforeach @if(in_array($request->status, ['pending', 'escalated']) && $request->currentApprover) @endif @if($request->approvals->count() == 0 && !in_array($request->status, ['pending', 'escalated'])) @endif
User Details Role & Permission Action Taken Comments Date & Time
{{ $request->submitter->name ?? 'Unknown' }}
{{ $request->submitter->email ?? '' }}
{{ $request->submitter->designation ?? $request->submitter->role ?? 'Submitter' }}
Request Originator
Submitted Initial request submission {{ $request->created_at->setTimezone('Asia/Kuala_Lumpur')->format('d/m/Y H:i') }}
{{ $request->created_at->setTimezone('Asia/Kuala_Lumpur')->diffForHumans() }}
@if($approval->decision == 'approved') @elseif($approval->decision == 'rejected') @elseif($approval->decision == 'escalated') @else @endif
{{ $approval->approver->name ?? 'Unknown' }}
{{ $approval->approver->email ?? '' }}
{{ $approval->approver->designation ?? $approval->approver->role ?? 'User' }} @if($approval->approver->is_approver)
Authorized Approver @endif
@if($approval->decision == 'approved') Approved @elseif($approval->decision == 'escalated') Escalated @elseif($approval->decision == 'rejected') Rejected @elseif($approval->decision == 'rejected_resubmit') Resubmission Required @else {{ ucfirst($approval->decision) }} @endif @if($approval->comments)
{{ $approval->comments }}
@else No comment provided @endif
{{ $approval->created_at->setTimezone('Asia/Kuala_Lumpur')->format('d/m/Y H:i') }}
{{ $approval->created_at->setTimezone('Asia/Kuala_Lumpur')->diffForHumans() }}
{{ $request->currentApprover->name }}
{{ $request->currentApprover->email ?? '' }}
{{ $request->currentApprover->designation ?? $request->currentApprover->role ?? 'User' }} @if($request->currentApprover->is_approver)
Authorized Approver @endif
Pending Review Awaiting action... -
No approval actions recorded yet.
@if($request->inventories && $request->inventories->count() > 0)

Requested Assets

@foreach($request->inventories as $inventory)
@if($inventory->image)
{{ $inventory->item_name }}
@else
@endif
{{ $inventory->item_name }}
Model: {{ $inventory->model ?? 'N/A' }}
Serial: {{ $inventory->serial_number ?? 'N/A' }}
Category: {{ $inventory->category->name ?? 'N/A' }}
@if($inventory->location)
Location: {{ $inventory->location->name }}
@endif
@endforeach
@endif

Itemized List

Complete breakdown of requested items with pricing
@php $items = is_array($request->items) ? $request->items : (is_string($request->items) ? json_decode($request->items, true) : []); @endphp
@forelse($items as $index => $item) @php $qty = (float)($item['quantity'] ?? 0); $unitCost = (float)($item['unit_cost'] ?? 0); $taxRate = (float)($item['tax_rate'] ?? 6); $deliveryCharge = (float)($item['delivery_charge'] ?? 0); $subtotal = $qty * $unitCost; $taxAmount = $subtotal * ($taxRate / 100); $calculatedTotal = $subtotal + $taxAmount + $deliveryCharge; @endphp @empty @endforelse
Item Name Qty Unit Cost (MYR) Tax Rate (%) Tax Amount (MYR) Delivery (MYR) Total Cost (MYR) Attachment
{{ $item['name'] ?? '' }}
@if(!empty($item['description'])) {{ $item['description'] }} @endif
{{ $qty }} {{ number_format($unitCost, 2) }} {{ number_format($taxRate, 2) }}% {{ number_format($taxAmount, 2) }} {{ $deliveryCharge > 0 ? number_format($deliveryCharge, 2) : '-' }} {{ number_format($calculatedTotal, 2) }} @if(!empty($item['attachment'])) @else - @endif

No items found for this request.
@if(!empty($request->pdf_path) || \Storage::exists('request_pdfs/request_' . str_pad($request->id, 3, '0', STR_PAD_LEFT) . '.pdf'))
Request PDF

The PDF is updated automatically with the latest approval history and status.

Download PDF View PDF Last updated: {{ $request->updated_at->format('d/m/Y H:i') }}
@endif @if((auth()->user()->id == $request->current_approver_id && in_array($request->status, ['pending', 'escalated'])) || (auth()->user()->canManageAllRequests() && in_array($request->status, ['pending', 'escalated'])) || (auth()->user()->is_approver && auth()->user()->id == $request->current_approver_id && in_array($request->status, ['pending', 'escalated'])))

You are authorized to approve, reject, or escalate this request

@endif {{-- Edit Request Section for Resubmission --}} @if($request->status == 'rejected_resubmit' && auth()->user()->id == $request->user_id)
Request Resubmission Required
Action Required

Your request has been reviewed and requires modifications before it can be approved. Please review the feedback below and make the necessary changes.

{{-- Show the rejection comment --}} @php $rejectionApproval = $request->approvals() ->where('decision', 'rejected_resubmit') ->latest() ->first(); @endphp @if($rejectionApproval)
Feedback from {{ $rejectionApproval->approver->name ?? 'Reviewer' }}:

{{ $rejectionApproval->comments }}

{{ $rejectionApproval->created_at->setTimezone('Asia/Kuala_Lumpur')->format('d/m/Y H:i') }}
@endif
After editing, your request will return to the approval workflow starting from the reviewer who requested changes.
@endif {{-- Information for other users when request is pending resubmission --}} @if($request->status == 'rejected_resubmit' && auth()->user()->id != $request->user_id)
Awaiting Resubmission

This request has been sent back to {{ $request->submitter->name ?? 'the requester' }} for modifications. The request will return to the approval workflow once the changes have been made and resubmitted.

@php $rejectionApproval = $request->approvals() ->where('decision', 'rejected_resubmit') ->latest() ->first(); @endphp @if($rejectionApproval && $rejectionApproval->comments)
Feedback Provided:

{{ $rejectionApproval->comments }}

By: {{ $rejectionApproval->approver->name ?? 'Reviewer' }} - {{ $rejectionApproval->created_at->setTimezone('Asia/Kuala_Lumpur')->format('d/m/Y H:i') }}
@endif
@endif
{{-- Take Action Modal --}} @if((auth()->user()->id == $request->current_approver_id && in_array($request->status, ['pending', 'escalated'])) || (auth()->user()->canManageAllRequests() && in_array($request->status, ['pending', 'escalated'])) || (auth()->user()->is_approver && auth()->user()->id == $request->current_approver_id && in_array($request->status, ['pending', 'escalated']))) @endif @endsection