@extends('layouts.default')
@section('content')
<div class="container-fluid">
    <div class="row mb-3"><div class="col"><h3>{{ $page_title }}</h3><p class="text-muted mb-0">{{ $client->company_name }} için {{ $page_description }}</p></div></div>
    @include('admin.onboarding._progress')

    <form method="POST" action="{{ route('admin.onboarding.report.save', $client) }}">
        @csrf
        <div class="row">
            <div class="col-xl-8">
                <div class="card"><div class="card-body">
                    <h5 class="mb-3">Otomatik Rapor Planı</h5>
                    <div class="row g-3">
                        <div class="col-md-6"><label class="form-label">Hazır Şablon</label><select name="report_template_id" class="form-control default-select"><option value="">Müşteriye özel yeni şablon oluştur</option>@foreach($templates as $template)<option value="{{ $template->id }}">{{ $template->client_id ? 'Müşteri' : 'Genel' }} — {{ $template->name }}</option>@endforeach</select></div>
                        <div class="col-md-3"><label class="form-label">Rapor Tipi</label><select name="report_type" class="form-control"><option value="weekly">Haftalık</option><option value="daily">Günlük</option><option value="monthly">Aylık</option></select></div>
                        <div class="col-md-3"><label class="form-label">Gönderim</label><select name="frequency" class="form-control"><option value="weekly">Haftalık</option><option value="daily">Günlük</option><option value="monthly">Aylık</option></select></div>
                        <div class="col-md-4"><label class="form-label">Saat</label><input name="daily_time" type="time" class="form-control" value="09:00"></div>
                        <div class="col-md-4"><label class="form-label">Haftalık Gün</label><select name="weekly_day" class="form-control"><option value="1">Pazartesi</option><option value="2">Salı</option><option value="3">Çarşamba</option><option value="4">Perşembe</option><option value="5">Cuma</option><option value="6">Cumartesi</option><option value="7">Pazar</option></select></div>
                        <div class="col-md-4"><label class="form-label">Aylık Gün</label><input name="monthly_day" type="number" min="1" max="28" class="form-control" value="1"></div>
                        <div class="col-md-12"><label class="form-label">Kanallar</label><div class="row">@foreach($platforms as $key => $label)<div class="col-md-3"><label class="form-check"><input type="checkbox" name="channels[]" value="{{ $key }}" class="form-check-input" checked> {{ $label }}</label></div>@endforeach</div></div>
                        <div class="col-md-12"><label class="form-label">Alıcılar</label><input name="recipients" class="form-control" value="{{ implode(', ', $client->report_recipients ?: []) }}" placeholder="mail1@site.com, mail2@site.com"></div>
                        <div class="col-md-6"><label class="form-label">CC</label><input name="cc" class="form-control"></div>
                        <div class="col-md-6"><label class="form-label">BCC</label><input name="bcc" class="form-control"></div>
                        <div class="col-md-12">
                            <label class="form-check form-check-inline"><input type="checkbox" name="include_pdf" value="1" class="form-check-input" checked> PDF Ekle</label>
                            <label class="form-check form-check-inline"><input type="checkbox" name="include_excel" value="1" class="form-check-input" checked> Excel Ekle</label>
                            <label class="form-check form-check-inline"><input type="checkbox" name="is_active" value="1" class="form-check-input" checked> Plan Aktif</label>
                        </div>
                    </div>
                </div></div>
            </div>
            <div class="col-xl-4">
                <div class="card"><div class="card-body">
                    <h5>Rapor akışı</h5>
                    <p class="text-muted">Bu adım sonunda zamanlanmış rapor planı oluşturulur. Cron çalıştığında rapor otomatik üretilir ve mail kuyruğuna alınır.</p>
                    <button class="btn btn-primary w-100">Kaydet ve Son Kontrole Geç</button>
                    <a href="{{ route('admin.onboarding.brand', $client) }}" class="btn btn-light w-100 mt-2">Geri</a>
                </div></div>
            </div>
        </div>
    </form>
</div>
@endsection
