@extends('admin.layouts.app') @section('title', $doc->title) @section('breadcrumbs') Dashboard Regulation Documents {{ Str::limit($doc->title, 40) }} @endsection @section('content') @php $extractionColors = ['pending'=>'#f59e0b','processing'=>'#3b82f6','completed'=>'#22c55e','failed'=>'#ef4444']; $reviewColors = ['pending'=>'#f59e0b','approved'=>'#22c55e','rejected'=>'#ef4444']; $rules = $doc->extracted_rules ?? []; @endphp {{-- Header --}}

{{ $doc->title }}

{{ $doc->original_filename }}  ·  {{ $doc->file_size_human }}  ·  Uploaded {{ $doc->created_at->diffForHumans() }} @if($doc->uploader) by {{ $doc->uploader->name }}@endif
← Back @if($doc->extraction_status !== 'processing')
@csrf
@endif
@if(session('success'))
{{ session('success') }}
@endif @if($errors->any())
{{ implode(', ', $errors->all()) }}
@endif {{-- Status row --}}
State / City
{{ $doc->state?->name ?? '—' }}
{{ $doc->city?->name ?? 'Any city' }}
AI Extraction
{{ ucfirst($doc->extraction_status) }} @if($doc->extraction_status === 'completed')
{{ count($rules) }} rules extracted
@endif
Review Status
{{ ucfirst($doc->review_status) }} @if($doc->reviewed_at)
{{ $doc->reviewed_at->format('d M Y') }}
@endif
Rules Applied
@if($doc->rules_applied) ✓ Yes @else Not yet @endif
@if($doc->ai_metadata)
AI Usage
{{ number_format($doc->ai_metadata['total_tokens'] ?? 0) }} tokens
{{ $doc->ai_metadata['chunks_processed'] ?? 0 }} chunks
@endif
@if($doc->extraction_status === 'failed')
Extraction Error
{{ $doc->extraction_error }}
@endif {{-- Review form (when extraction completed, review pending) --}} @if($doc->extraction_status === 'completed' && $doc->review_status === 'pending')

Admin Review Required

@csrf
@endif {{-- Apply rules (when approved, not yet applied) --}} @if($doc->review_status === 'approved' && !$doc->rules_applied && count($rules) > 0)

Apply Rules to Database

This will push the extracted rules into the Zone Rules table. Existing rules for matching zones will be updated.

@csrf
@endif {{-- Extracted rules preview --}} @if(count($rules) > 0)
AI-Extracted Rules ({{ count($rules) }})
AI confidence shown per rule
@foreach($rules as $i => $rule) @if(!empty($rule['special_conditions'])) @endif @endforeach
# Zone FAR Coverage% Floors Height(m) Setbacks F/R/S Permitted Uses Confidence
{{ $i+1 }}
{{ $rule['zone_name'] ?? '—' }}
{{ $rule['zone_code'] ?? '' }}
@if(isset($rule['far_min']) || isset($rule['far_max'])) {{ $rule['far_min'] ?? '' }}{{ isset($rule['far_min']) && isset($rule['far_max']) ? '–' : '' }}{{ $rule['far_max'] ?? '' }} @else — @endif {{ $rule['ground_coverage_pct'] ?? '—' }}{{ isset($rule['ground_coverage_pct']) ? '%' : '' }} {{ $rule['max_floors'] ?? '—' }} {{ $rule['max_height_m'] ?? '—' }} {{ $rule['front_setback_m'] ?? '?' }} / {{ $rule['rear_setback_m'] ?? '?' }} / {{ $rule['side_setback_m'] ?? '?' }} @foreach(array_slice($rule['permitted_uses'] ?? [], 0, 3) as $use) {{ $use }} @endforeach @if(count($rule['permitted_uses'] ?? []) > 3) +{{ count($rule['permitted_uses']) - 3 }} @endif @php $conf = (float)($rule['confidence'] ?? 0); @endphp
{{ round($conf*100) }}%
ℹ {{ $rule['special_conditions'] }}
@endif {{-- Text chunks preview --}} @if($doc->extracted_text_chunks && count($doc->extracted_text_chunks) > 0)
@foreach(array_slice($doc->extracted_text_chunks, 0, 3) as $idx => $chunk)
Chunk {{ $idx + 1 }}
{{ Str::limit($chunk, 600) }}
@endforeach @if(count($doc->extracted_text_chunks) > 3)
... {{ count($doc->extracted_text_chunks) - 3 }} more chunks not shown
@endif
@endif @endsection