@extends('layouts.admin.theme')
@php $tituloHeader = env("APP_NAME") . " :: Página de Acompanhamento, Processo nº {$processo->numero}"; @endphp
@section("title", $tituloHeader)
@section('content')


    <div class="container mt-4">
        <div class="row">
            <div class="col-12">
                <div class="card shadow">
                    <div class="card-header bg-primary text-white d-flex justify-content-between align-items-center mb-3">
                        <h5 class="mb-0">{{ "Página de Acompanhamento, Processo nº {$processo->numero}" }}</h5>
                    </div>
                    <div class="card-body">
                        <div class="mb-3 text-wrap">
                            <label for="sobre" class="form-label text-bold"><strong>Pertence a:</strong></label><br>
                            {{ $processo->user->firstName }} {{ $processo->user->lastName }}, Matrícula: {{ $processo->user->matriculation }}
                        </div>
                        <div class="mb-3 text-wrap">
                            <label for="sobre" class="form-label text-bold"><strong>Sobre este processo:</strong></label>
                            {!! $processo->descricao !!}
                        </div>
                        <div class="mb-3 text-wrap">
                            <label for="andamento" class="form-label text-bold"><strong>Andamento:</strong></label><br>
                            {{ $processo->andamento_descricao }}
                        </div>
                        <div class="mb-3 text-wrap">
                            <label for="status" class="form-label text-bold"><strong>Status:</strong></label><br>
                            {{ $processo->status === 'ATIVADO' ? 'Ativado' : 'Desativado' }}
                        </div>
                        <div class="mb-3">
                            <label for="interessados" class="form-label text-bold">
                                Interessados: <span class="span-admin-create">*</span>
                            </label>

                            <div id="interessados-wrapper">
                                @foreach($interessados as $interessado)  
                                    @if($interessado["matriculation"] != Auth::user()->matriculation)
                                        <div class="input-group mb-2">
                                            <input type="text" class="form-control" name="interessados[]" autocomplete="off" oninput="this.value = this.value.replace(/[^0-9]/g, '')" value="{{ $interessado["firstName"] }} {{ $interessado["lastName"] }}, Matricula: {{ $interessado["matriculation"] }}" readonly="true">
                                        </div>
                                    @endif
                                @endforeach
                            </div>

                        @error('interessados')
                            <small class="text-danger text-bold">{{ $message }}</small>
                        @enderror
                    </div>
                    <hr>
                    @foreach($processo->comentarios as $comentario)
                        <div class="mb-3 text-wrap">
                            <label for="sobre" class="form-label text-bold"><strong>Comentário em:</strong> {{ date("d/m/Y H:m:s", strtotime($comentario->created_at)) }}</label>
                            {!! $comentario->comentario !!}
                        </div>
                    <hr>
                    @endforeach
                    <form action="{{ route('admin.processos.acompanhamento', $processo->id) }}" method="post" enctype="multipart/form-data">
                        @csrf
                        @method('POST')
                        @include("errors.messageFlash")
                        <div class="mb-3 text-wrap">
                            <label for="descricao" class="form-label text-bold">Incluir novo comentário:</label>
                            <textarea class="form-control textarea-comments @error('descricao') is-invalid @enderror" style="height: 200px" name="descricao" id="descricao">{{ old('descricao') }}</textarea>
                            @error('descricao')
                                <small class="text-danger text-bold">{{ $message }}</small>
                            @enderror
                        </div>
                        @include('components.buttons._backAndSend', [
                            'routeBack' => 'admin.processos.index', 'textBack' => 'Voltar', 'textSend' => 'Salvar'
                        ])
                    </form>
                </div>
            </div>
        </div>
    </div>
    </div>


@endsection