@extends('layouts.admin')
@section('title','Laporan Revenue')
@section('content')
<div class="card mb-3"><div class="card-body py-2"><form class="row g-2" method="GET"><div class="col-md-3"><label class="form-label small">Tahun</label><input type="number" name="year" class="form-control form-control-sm" value="{{ $year }}"></div><div class="col-auto d-flex align-items-end"><button type="submit" class="btn btn-primary btn-sm">Filter</button></div></form></div></div>
<div class="row g-3 mb-3">
  @foreach(['JPN','FixLab','Havva'] as $div)
  <div class="col-md-4"><div class="card p-3 text-center"><div class="text-muted small">{{ $div }}</div><div class="fw-bold fs-5">Rp {{ number_format($byDivision[$div]??0,0,',','.') }}</div></div></div>
  @endforeach
</div>
<div class="card">
  <div class="card-header">Revenue Bulanan {{ $year }}</div>
  <div class="table-responsive">
    <table class="table table-hover mb-0">
      <thead><tr><th>Bulan</th><th class="text-end">Revenue</th></tr></thead>
      <tbody>
      @for($m=1;$m<=12;$m++)
      <tr>
        <td>{{ date('F',mktime(0,0,0,$m,1)) }}</td>
        <td class="text-end fw-semibold {{ ($monthly[$m]??0)>0?'text-success':'' }}">Rp {{ number_format($monthly[$m]??0,0,',','.') }}</td>
      </tr>
      @endfor
      </tbody>
      <tfoot><tr class="fw-bold"><td>Total</td><td class="text-end">Rp {{ number_format(array_sum($monthly->toArray()),0,',','.') }}</td></tr></tfoot>
    </table>
  </div>
</div>
@endsection
