{{-- @php var_dump($user); @endphp --}}
@if(isset($user->StakeholderUser->first_name)) {{ $user->StakeholderUser->first_name }} {{ $user->StakeholderUser->last_name }} @else {{ session('user_name', 'Authorized Partner') }} @endif
@csrf
{{ session('active_project_title', 'Dashboard Overview') }}
@if(session('active_project_no')) Project No: {{ session('active_project_no') }} @else No Project Selected @endif
{{-- @php var_dump($project) @endphp --}}
Welcome to your Dashboard

Please use the dropdown selector menu inside the toolbar interface directly above to populate project data fields.

{{-- @foreach($projects as $project) --}} @php // $isActive = session('active_project_id') == $project->id; $isActive = true; @endphp

{{ $project->title }}

{{-- Active Long-Term Profile --}}

Project No

{{ $project->project_no }}

Budget Allocation

{{ number_format($project->budget, 2) }}LKR

Project Duration

Start Date: {{ \Carbon\Carbon::parse($project->start_date)->format('Y-m-d') }}

Estimated End Date: {{ \Carbon\Carbon::parse($project->end_date)->format('Y-m-d') }}

Project Description

{{ $project->description }}

{{--

Administrative Remarks

{{ $project->remark ?? 'No explicit operational adjustments noted.' }}

--}}
{{-- @endforeach --}} @php // Dummy fallback statuses (remove if real DB values exist) $statusList = ['pending', 'in_progress', 'completed']; @endphp
Project Activities
@forelse($project->longTermProjectActivities as $activity) @php $totalWeight = 0; $completedWeight = 0; // 1. Activity weight $totalWeight += $activity->activity_weight ?? 0; if ($activity->state === 'COMPLETED') { $completedWeight += $activity->activity_weight ?? 0; } elseif ($activity->state === 'IN_PROGRESS') { // nothing added unless completed } // 2. Sub activities weight foreach ($activity->longTermProjectSubActivities as $sub) { $totalWeight += $sub->sub_activity_weight ?? 0; if ($sub->state === 'COMPLETED') { $completedWeight += $sub->sub_activity_weight ?? 0; } } // echo '
';
                    //     print_r($totalWeight);
                    //  echo '
'; // 3. Final percentage $percentage = $totalWeight > 0 ? round(($completedWeight / $totalWeight) * 100) : 0; // 4. Force full completion if ($activity->state === 'COMPLETED') { $percentage = 100; } @endphp
{{ $activity->activity_name }}
{{-- {{ $completedWeight }} --}}

{{ $activity->activity_description }}

{{ $percentage }}%
@forelse($activity->longTermProjectComments as $comment)
{{ \Carbon\Carbon::parse($comment->created_at)->format('Y-m-d H:i') }} {{ $comment->stackholder_category ?? 'EXTERNAL' }}
{{ $comment->comments }}
@empty {{--

No comments yet

--}}

@endforelse
{{--
--}}
@forelse($activity->longTermProjectSubActivities as $sub) @php $status = $sub->status ?? 'pending'; @endphp
{{ $sub->sub_activity_name }}
LKR {{ number_format($sub->cost, 2) }} @php $state = $sub->state; $stateClasses = [ 'PENDING' => 'bg-secondary-subtle text-secondary border', 'IN_PROGRESS' => 'bg-warning-subtle text-warning border', 'COMPLETED' => 'bg-success-subtle text-success border', 'DELETED' => 'bg-danger-subtle text-danger border', ]; $stateLabel = ucwords(strtolower(str_replace('_', ' ', $state))); @endphp {{ $stateLabel }}

{{ $sub->sub_activity_description }}

{{-- {{ ucfirst(str_replace('_',' ',$status)) }} --}}
@forelse($sub->longTermProjectComments as $comment) @php $organization = 'N/A'; $first_name = 'N/A'; $last_name = ''; $stakeholderCategory = ucwords(str_replace("-", " ", $comment->stackholder_category)); if($comment->stackholder_category == 'EXTERNAL'){ $subActivityUsers = DB::table('long_term_project_stakeholder_user') ->where('stakeholder_category', 'EXTERNAL') ->where('id', $comment->stakeholder_id) ->first(); if($subActivityUsers) { $organization = $subActivityUsers->organization ?? 'N/A'; $first_name = $subActivityUsers->name ?? 'N/A'; $last_name = $subActivityUsers->last_name ?? ''; } } elseif($comment->stackholder_category == 'COLLABORATIVE_PARTNER'){ $subActivityUsers = DB::table('long_term_project_stakeholder_user') ->where('stakeholder_category', 'COLLABORATIVE_PARTNER') ->where('id', $comment->stakeholder_id) ->join('collaborative_partners', 'long_term_project_stakeholder_user.collaborative_partner_id', '=', 'collaborative_partners.id') ->select('collaborative_partners.name as organization_name', 'collaborative_partners.name as first_name') ->first(); if($subActivityUsers) { $organization = $subActivityUsers->organization_name ?? 'N/A'; $first_name = $subActivityUsers->first_name ?? 'N/A'; $last_name = ''; // Collaborative partners might not have last_name } } elseif($comment->stackholder_category == 'SYSTEM'){ $subActivityUsers = DB::table('users') ->where('id', $comment->stakeholder_id) ->first(); if($subActivityUsers) { $organization = 'SYSTEM'; $first_name = $subActivityUsers->name ?? 'N/A'; $last_name = $subActivityUsers->last_name ?? ''; } } @endphp
{{ $first_name ?? '' }} {{ $last_name ?? '' }} ({{ $organization }} | {{ ucwords(strtolower(str_replace("-", " ", $stakeholderCategory))) }})
{{ $comment->created_at->format('Y-m-d H:i') }}
{{ $comment->comments }}
@if($comment->documents && $comment->documents->count() > 0)
Attachments
@foreach($comment->documents as $doc) @endforeach
@endif
@empty

No sub comments

@endforelse

{{--
@php $hasComments = $sub->longTermProjectComments()->exists(); @endphp

--}} {{-- @if($sub->longTermProjectSubActivityDocuments->count() > 0)
Uploaded Documents
@foreach($sub->longTermProjectSubActivityDocuments as $document)
{{ $document->file_name ?? 'Attachment' }}
{{ \Carbon\Carbon::parse($document->created_at)->format('Y-m-d H:i') }}
View
@endforeach
@endif --}}
@empty

No sub activities available

@endforelse
@empty

No activities found for this project.

@endforelse