@extends('layouts.app') @section('title', 'View Enquiry') @section('content')

{{ ucfirst(str_replace('_', ' ', $enquiry->type)) }} Details

Complete enquiry information and processing status

Back to List @if($enquiry->registered_by == auth()->user()->id && $enquiry->status == 'pending') Edit @endif
APPLICANT INFORMATION
@if(auth()->user()->hasRole('registrar_hq')) @if(in_array($enquiry->status, ['pending', 'pending_overdue'])) @elseif(in_array($enquiry->status, ['assigned', 'pending_overdue'])) @endif @endif @if($enquiry->registered_by == auth()->user()->id && $enquiry->status == 'pending') Edit @endif @if($enquiry->registered_by == auth()->user()->id && in_array($enquiry->status, ['pending', 'rejected']) && $enquiry->status != 'assigned')
@csrf @method('DELETE')
@endif
Full Name {{ $enquiry->full_name }}
Force Number {{ $enquiry->force_no }}
Phone {{ $enquiry->phone }}
Date Received {{ $enquiry->date_received }}
Check Number {{ $enquiry->check_number }}
Enquiry Type {{ ucfirst(str_replace('_', ' ', $enquiry->type)) }}
Account Number {{ $enquiry->account_number }}
Bank Name {{ $enquiry->bank_name }}
Region {{ $enquiry->region->name ?? 'No Region' }}
District {{ $enquiry->district->name ?? 'No District' }}
Attached Documents
@if ($enquiry->folios->isNotEmpty())
@foreach ($enquiry->folios as $index => $folio) @if (strtolower(pathinfo($folio->file_path, PATHINFO_EXTENSION)) === 'pdf')

{{ basename($folio->file_path) }}

Download
@else
📎

{{ basename($folio->file_path) }}

Download
@endif @endforeach
@else
📭

No documents

@endif
REGISTRAR & ASSIGNED USERS
REGISTRAR
Name {{ $enquiry->registeredBy->name ?? 'N/A' }}
Command {{ $enquiry->registeredBy->command->name ?? 'N/A' }}
Phone {{ $enquiry->registeredBy->phone_number ?? 'N/A' }}
Region {{ $enquiry->registeredBy->region->name ?? 'N/A' }}
District {{ $enquiry->registeredBy->district->name ?? 'N/A' }}
ASSIGNED TO
@if ($enquiry->assignedUsers->isNotEmpty()) @foreach ($enquiry->assignedUsers as $assignedUser)
Name {{ $assignedUser->name }}
Phone {{ $assignedUser->phone_number ?? 'N/A' }}
Region {{ $assignedUser->region->name ?? 'N/A' }}
District {{ $assignedUser->district->name ?? 'N/A' }}
Role {{ $enquiry->users->first()->getRoleNames()->first() ?? 'N/A' }}
@endforeach @else
Not yet assigned
@endif
@if ($enquiry->folios->isNotEmpty()) @foreach ($enquiry->folios as $index => $folio) @if (strtolower(pathinfo($folio->file_path, PATHINFO_EXTENSION)) === 'pdf') @endif @endforeach @endif @if($enquiry->childData)
{{ ucfirst(str_replace('_', ' ', $enquiry->type)) }} Specific Details
@switch($enquiry->type) @case('loan_application') @if($enquiry->loanApplication)
Requested Amount {{ number_format($enquiry->loanApplication->requested_amount ?? 0, 0) }} TZS
Processed Amount {{ number_format($enquiry->loanApplication->loan_amount ?? 0, 0) }} TZS
Loan Duration {{ $enquiry->loanApplication->loan_duration ?? 'N/A' }} months
Interest Rate {{ $enquiry->loanApplication->interest_rate ?? 'N/A' }}%
Monthly Deduction {{ number_format($enquiry->loanApplication->monthly_deduction ?? 0, 0) }} TZS
Total Loan with Interest {{ number_format($enquiry->loanApplication->total_loan_with_interest ?? 0, 0) }} TZS
Total Interest {{ number_format($enquiry->loanApplication->total_interest ?? 0, 0) }} TZS
Processing Fee {{ number_format($enquiry->loanApplication->processing_fee ?? 0, 0) }} TZS
Insurance {{ number_format($enquiry->loanApplication->insurance ?? 0, 0) }} TZS
Disbursement Amount {{ number_format($enquiry->loanApplication->disbursement_amount ?? 0, 0) }} TZS
Loan Purpose {{ $enquiry->loanApplication->loan_type ?? 'N/A' }}
@endif @break @case('refund') @if($enquiry->refund)
Refund Amount {{ number_format($enquiry->refund->refund_amount ?? 0, 0) }} TZS
Refund Duration {{ $enquiry->refund->refund_duration ?? 'N/A' }} months
@endif @break @case('retirement') @if($enquiry->retirement)
Date of Retirement: {{ $enquiry->retirement->date_of_retirement ?? 'N/A' }}
@endif @break @case('condolences') @if($enquiry->condolence)
Gender: {{ ucfirst($enquiry->condolence->gender ?? 'N/A') }}
Dependent Member Type: {{ ucfirst($enquiry->condolence->dependent_member_type ?? 'N/A') }}
@endif @break @case('deduction_add') @if($enquiry->deduction)
From Amount: {{ number_format($enquiry->deduction->from_amount ?? 0, 0) }} TZS
To Amount: {{ number_format($enquiry->deduction->to_amount ?? 0, 0) }} TZS
Change: {{ number_format($enquiry->deduction->changes ?? 0, 0) }} TZS
Status: {{$enquiry->deduction->status ?? 'N/A' }}
@endif @break @case('injured_at_work') @if($enquiry->injury)
@if($enquiry->injury->description)
Injury Description: {{ $enquiry->injury->description }}
@endif
@endif @break @case('share_enquiry') @case('withdraw_savings') @case('withdraw_deposit') {{-- Hizi kesi zina data nyingi, List Group Items zinafaa zaidi kutumika bila gridi ili zionekane vizuri wima. Lakini kwa kuwa tayari ulikuwa na gridi, nitaziweka kwenye List Group Items za kiwango kimoja kwa kila kisa cha kujirudia ili kufanya iwe wima. --}} {{-- Kwa case ya 'share_enquiry' --}} @if($enquiry->type == 'share_enquiry' && $enquiry->share)
Share Amount: {{ number_format($enquiry->share->share_amount ?? 0, 0) }} TZS
@endif {{-- Kwa case ya 'withdraw_savings' au 'withdraw_deposit' (Zote zina data sawa) --}} @if(($enquiry->type == 'withdraw_savings' || $enquiry->type == 'withdraw_deposit') && $enquiry->withdrawal)
Withdrawal Amount: {{ number_format($enquiry->withdrawal->amount ?? 0, 0) }} TZS
Withdrawal Type: {{ ucfirst($enquiry->withdrawal->type ?? str_replace('_', ' ', $enquiry->type)) }}
Request Date: {{ $enquiry->withdrawal->created_at?? 'N/A' }}
Reason: {{ $enquiry->withdrawal->reason?? 'N/A' }}
Days: {{ $enquiry->withdrawal->days?? 'N/A' }}
@endif @break {{-- break inafaa hapa baada ya kumaliza 'withdraw' cases zote --}} @case('join_membership') @case('unjoin_membership') @if($enquiry->membershipChange)
Category: {{ ucfirst($enquiry->membershipChange->category ?? 'N/A') }}
Action: {{ ucfirst($enquiry->membershipChange->action ?? 'N/A') }}
@endif @break @case('sick_for_30_days') @if($enquiry->sickLeave)
Start Date: {{ $enquiry->sickLeave->startdate ?? 'N/A' }}
End Date: {{ $enquiry->sickLeave->enddate ?? 'N/A' }}
Total Days: {{ $enquiry->sickLeave->days ?? 'N/A' }}
@endif @break @case('ura_mobile') @if($enquiry->uraMobile)
Service Type: {{ $enquiry->uraMobile->service_type ?? 'N/A' }}
Phone Number: {{ $enquiry->uraMobile->phone_number ?? 'N/A' }}
@endif @break @case('residential_disaster') @if($enquiry->residentialDisaster)
Disaster Type: {{ ucfirst($enquiry->residentialDisaster->disaster_type ?? 'N/A') }}
@endif @break @default
No specific details available for this enquiry type

General enquiry information is displayed in the sections above.

@endswitch
@endif
Enquiry Timeline & Status History
Enquiry Registered
{{ $enquiry->created_at->format('M d, Y - H:i') }}

Enquiry submitted by {{ $enquiry->registeredBy->name ?? 'System' }}

Type: {{ ucfirst(str_replace('_', ' ', $enquiry->type)) }}
@php $now = now(); $isOverdue = $enquiry->status == 'pending' && $enquiry->created_at->diffInWeekdays($now) >= 3; $hasAssignment = $enquiry->users->count() > 0; @endphp
@if($hasAssignment) Assigned to User @else Awaiting Assignment @endif
@if($hasAssignment) {{ $enquiry->updated_at->format('M d, Y - H:i') }} @endif
@if($hasAssignment)

Assigned to {{ $enquiry->users->first()->name }}

Role: {{ $enquiry->users->first()->getRoleNames()->first() }}
@else

Waiting for assignment to appropriate officer

@if($isOverdue) Overdue ({{ $enquiry->created_at->diffInWeekdays($now) }} days) @endif
@endif
@php // Define enquiry types that require review completion $reviewCompletionTypes = [ 'refund', 'share_enquiry', 'retirement', 'deduction_add', 'withdraw_savings', 'withdraw_deposit', 'unjoin_membership', 'ura_mobile', 'sick_for_30_days', 'condolences', 'injured_at_work', 'residential_disaster', 'join_membership' ]; $isReviewType = in_array($enquiry->type, $reviewCompletionTypes); $isLoanType = $enquiry->type == 'loan_application'; @endphp
@if($enquiry->status == 'approved') @elseif($enquiry->status == 'rejected') @elseif($enquiry->status == 'completed') @elseif($enquiry->status == 'processed') @else @endif
@if($enquiry->status == 'approved') @elseif($enquiry->status == 'rejected') @elseif(in_array($enquiry->status, ['completed', 'processed'])) @endif @if($enquiry->status == 'approved') @if($isLoanType) Loan Approved @else Enquiry Approved @endif @elseif($enquiry->status == 'rejected') Enquiry Rejected @elseif($enquiry->status == 'completed') Review Completed @elseif($enquiry->status == 'processed') @if($isLoanType) Loan Processed @else Processing Completed @endif @else @if($isLoanType) Awaiting Processing @else Awaiting Review @endif @endif
@if(in_array($enquiry->status, ['approved', 'rejected', 'completed', 'processed'])) {{ $enquiry->updated_at->format('M d, Y - H:i') }} @endif
@if($enquiry->status == 'approved') @if($isLoanType)

Loan application has been approved by manager

@else

Enquiry approved and ready for final processing

@endif @elseif($enquiry->status == 'rejected')

Enquiry was rejected by the reviewing officer

@php $rejection = \App\Models\Rejection::where('enquiry_id', $enquiry->id)->latest()->first(); @endphp @if($rejection)
Rejection Reason:

{{ $rejection->reason_text }}

@if($rejection->rejection_detail) Details: {{ $rejection->rejection_detail }} @endif
Rejected by: {{ $rejection->rejectedBy->name ?? 'System' }} • {{ $rejection->created_at->format('M d, Y H:i') }}
@endif @elseif($enquiry->status == 'completed') @if($isReviewType)

Review process completed successfully

@else

Enquiry has been reviewed and completed

@endif @elseif($enquiry->status == 'processed') @if($isLoanType)

Loan has been processed by loan officer, awaiting manager approval

@else

Enquiry has been fully processed

@endif @elseif($enquiry->status == 'assigned')

Awaiting review by assigned officer

@else @if($isLoanType)

Pending processing by loan officer

@else

Pending review and decision

@endif @endif
@if( ($isLoanType && $enquiry->status == 'approved') || ($isReviewType && $enquiry->status == 'completed') || (!$isLoanType && !$isReviewType && $enquiry->status == 'processed') )
Process Completed
{{ $enquiry->updated_at->format('M d, Y - H:i') }}
@if($isLoanType)

Loan application successfully approved and completed

All approval steps completed @elseif($isReviewType)

Enquiry review completed successfully

All required actions have been taken @else

Enquiry processing completed

All required actions have been taken @endif
@else
Awaiting Completion
@if($isLoanType)

Awaiting loan approval decision

@elseif($isReviewType)

Awaiting review completion

@else

Awaiting final processing

@endif
@endif
Current Status
Last updated: {{ $enquiry->updated_at->diffForHumans() }}
@if($isOverdue) Overdue ({{ $enquiry->created_at->diffInWeekdays($now) }} days) @else {{ ucwords($enquiry->status) }} @endif
@include('modals.assign_enquries') @if($enquiry->users->count() > 0) @include('modals.reassign_enquiry') @endif @endsection