@extends('layouts.app')
@section('content')
<main class="main-content"><div class="container-fluid"><h4 class="mb-4">Customer Success, Renewals & SLA</h4>@if(session('success'))<div class="alert alert-success">{{ session('success') }}</div>@endif
<div class="row g-3"><div class="col-lg-6"><div class="card"><div class="card-body"><h5>Renewal Opportunity</h5><form method="POST" action="{{ route('operations.renewals.store') }}" class="row g-2">@csrf<select name="account_id" class="form-select" required><option value="">Account</option>@foreach($accounts as $a)<option value="{{ $a->id }}">{{ $a->account_name }}</option>@endforeach</select><input type="date" name="renewal_date" class="form-control" required><input type="number" step=".01" name="value" class="form-control" placeholder="Value" required><select name="owner_id" class="form-select"><option value="">Owner</option>@foreach($users as $u)<option value="{{ $u->id }}">{{ $u->name }}</option>@endforeach</select><textarea name="notes" class="form-control" placeholder="Notes"></textarea><button class="btn btn-primary">Create renewal</button></form></div></div></div>
<div class="col-lg-6"><div class="card"><div class="card-body"><h5>Customer Health</h5><form method="POST" action="{{ route('operations.health.store') }}" class="row g-2">@csrf<select name="account_id" class="form-select" required><option value="">Account</option>@foreach($accounts as $a)<option value="{{ $a->id }}">{{ $a->account_name }}</option>@endforeach</select><input name="score" type="number" min="0" max="100" class="form-control" placeholder="Health score" required><select name="status" class="form-select" required><option value="healthy">Healthy</option><option value="watch">Watch</option><option value="at_risk">At risk</option></select><textarea name="notes" class="form-control" placeholder="Notes"></textarea><button class="btn btn-primary">Record health</button></form></div></div></div></div>
<div class="card mt-3"><div class="card-body"><h5>SLA Policies</h5><form method="POST" action="{{ route('operations.sla.store') }}" class="d-flex gap-2">@csrf<select name="priority" class="form-select"><option>low</option><option>medium</option><option>high</option><option>urgent</option></select><input name="resolution_hours" type="number" min="1" class="form-control" placeholder="Resolution hours" required><button class="btn btn-primary">Save SLA</button></form><form method="POST" action="{{ route('operations.sla.refresh') }}" class="mt-2">@csrf<button class="btn btn-outline-primary">Refresh breaches</button></form></div></div>
<div class="card mt-3"><div class="card-body"><h5>Invoice Schedule</h5><form method="POST" action="{{ route('operations.invoice-schedules.store') }}" class="row g-2">@csrf<select name="account_id" class="form-select" required><option value="">Account</option>@foreach($accounts as $a)<option value="{{ $a->id }}">{{ $a->account_name }}</option>@endforeach</select><select name="frequency" class="form-select"><option value="one_time">One time</option><option value="monthly">Monthly</option><option value="quarterly">Quarterly</option><option value="yearly">Yearly</option></select><input type="date" name="next_invoice_date" class="form-control" required><input name="amount" type="number" step=".01" class="form-control" placeholder="Amount" required><input name="currency" class="form-control" value="USD" required><input name="payment_terms" class="form-control" value="Due on receipt" required><textarea name="description" class="form-control" placeholder="Invoice description" required></textarea><button class="btn btn-primary">Create schedule</button></form></div></div>
<div class="row mt-3"><div class="col-lg-6"><h5>Upcoming renewals</h5><ul class="list-group">@forelse($renewals as $x)<li class="list-group-item">Account #{{ $x->account_id }} · {{ $x->renewal_date }} · {{ number_format($x->value,2) }}</li>@empty<li class="list-group-item text-muted">None</li>@endforelse</ul></div><div class="col-lg-6"><h5>SLA breaches</h5><ul class="list-group">@forelse($breaches as $x)<li class="list-group-item">Case #{{ $x->case_id }} · breached {{ $x->breached_at }}</li>@empty<li class="list-group-item text-muted">None</li>@endforelse</ul></div></div></div></main>
<div class="card mt-3"><div class="card-body"><h5>Update Renewal</h5><form method="POST" action="{{ route('operations.renewals.status', 0) }}" class="row g-2" onsubmit="this.action=this.action.replace('/0/status','/'+this.renewal_id.value+'/status')">@csrf<input name="renewal_id" type="number" min="1" class="form-control" placeholder="Renewal ID" required><select name="status" class="form-select" required><option value="open">Open</option><option value="engaged">Engaged</option><option value="renewed">Renewed</option><option value="lost">Lost</option><option value="cancelled">Cancelled</option></select><input name="notes" class="form-control" placeholder="Status note (required for lost)"><button class="btn btn-outline-primary">Update renewal</button></form></div></div>
@endsection
