@extends('layouts.app')

@section('content')
    <div class="container">
        <div class="row">
            <div class="col">
                <form action="">
                    <div class="row">
                        <div class="col-4">
                            <input type="text" class="form-control" name="s" value="{{ request()->input('s') }}">
                        </div>
                        <div class="col">
                            <x-form-control-select name="project_status" :options="$statuses" value="{{ request()->input('project_status') }}"></x-form-control-select>
                        </div>
                        <div class="col">
                            <button class="btn btn-primary">搜尋</button>
                            <a class="btn btn-success text-white" href="{{ route('adm.project.create') }}">
                                <i class="bi bi-plus"></i>
                            </a>
                        </div>
                    </div>
                </form>

            </div>
        </div>

        <div class="row">
            <div class="col">
                <table class="table table-striped">
                    <thead>
                        <tr>
                            <th>ID</th>
                            <th>名稱</th>
                            <th>狀態</th>
                            <th>金額</th>
                            <th>未收款項</th>
                            <th>已收款項</th>
                            <th>客戶</th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody>
                    @foreach($projects as $project)
                        <tr>
                            <td>{{ $project->id }}</td>
                            <td>{{ $project->title }}</td>
                            <td>
                                <span class="badge @if($project->status == \App\Models\Project::STATUS_CLOSED) bg-success @else bg-warning @endif">
                                    {{ __('enums.project_status.' . $project->status) }}
                                </span>
                            </td>
                            <td>{{ $project->price }}</td>
                            <td>{{ $project->unpaid_amount }}</td>
                            <td>{{ $project->paid_amount }}</td>
                            <td>{{ $project->client->name }}</td>
                            <td>
                                <a href="{{ route('adm.project.show', [$project->id]) }}" class="btn btn-sm btn-primary">
                                    <i class="bi bi-eye"></i>
                                </a>
                                <a href="{{ route('adm.project.edit', [$project->id]) }}" class="btn btn-sm btn-outline-secondary">
                                    <i class="bi bi-pencil"></i>
                                </a>
                            </td>
                        </tr>
                    @endforeach
                    </tbody>
                </table>
            </div>
        </div>
    </div>
@endsection
