<?php $this->start('body');
    include __DIR__ . '/_dash_header.php';
    include __DIR__ . '/_kpi_strip.php';
?>

<div class="row g-3">
  <div class="col-lg-4">
    <div class="card border-0 shadow-sm h-100"><div class="card-body">
      <div class="d-flex justify-content-between align-items-baseline mb-2">
        <h6 class="text-uppercase text-muted small mb-0">Bill lifecycle</h6>
        <a href="<?= PROOT; ?>SupplierBills" class="small text-decoration-none">All &rarr;</a>
      </div>
      <div id="c-funnel" style="min-height: 260px;"></div>
    </div></div>
  </div>
  <div class="col-lg-8">
    <div class="card border-0 shadow-sm h-100"><div class="card-body">
      <div class="d-flex justify-content-between align-items-baseline mb-2">
        <h6 class="text-uppercase text-muted small mb-0">Daily cash &middot; last 60 days</h6>
        <a href="<?= PROOT; ?>FinancialReports/cashFlow" class="small text-decoration-none">Cash Flow &rarr;</a>
      </div>
      <div id="c-cash" style="min-height: 260px;"></div>
    </div></div>
  </div>
</div>

<div class="row g-3 mt-1">
  <div class="col-lg-7">
    <div class="card border-0 shadow-sm h-100"><div class="card-body">
      <div class="d-flex justify-content-between align-items-baseline mb-2">
        <h6 class="text-uppercase text-muted small mb-0">Receipts vs Payments &middot; last 6 months</h6>
        <a href="<?= PROOT; ?>Journals" class="small text-decoration-none">Journals &rarr;</a>
      </div>
      <div id="c-flows" style="min-height: 260px;"></div>
    </div></div>
  </div>
  <div class="col-lg-5">
    <div class="card border-0 shadow-sm h-100"><div class="card-body">
      <div class="d-flex justify-content-between align-items-baseline mb-2">
        <h6 class="text-uppercase text-muted small mb-0">Expense mix &middot; YTD</h6>
        <a href="<?= PROOT; ?>FinancialReports/pnl" class="small text-decoration-none">P&amp;L &rarr;</a>
      </div>
      <div id="c-mix" style="min-height: 260px;"></div>
    </div></div>
  </div>
</div>

<!-- Zone 3 · Attention + Zone 4 · Activity -->
<div class="row g-3 mt-1">
  <div class="col-lg-6"><?php include __DIR__ . '/_feed_bills.php'; ?></div>
  <div class="col-lg-6"><?php include __DIR__ . '/_feed_compliance.php'; ?></div>
</div>

<div class="row g-3 mt-1">
  <div class="col-12">
    <div class="card border-0 shadow-sm"><div class="card-body">
      <h6 class="text-uppercase text-muted small mb-3">Month-end shortcuts</h6>
      <div class="d-flex flex-wrap gap-2">
        <a href="<?= PROOT; ?>FinancialReports/trialBalance" class="btn btn-sm btn-outline-primary"><i class="fas fa-scale-balanced me-1"></i>Trial Balance</a>
        <a href="<?= PROOT; ?>FinancialReports/pnl" class="btn btn-sm btn-outline-primary"><i class="fas fa-hand-holding-dollar me-1"></i>P&amp;L</a>
        <a href="<?= PROOT; ?>FinancialReports/balanceSheet" class="btn btn-sm btn-outline-primary"><i class="fas fa-building-columns me-1"></i>Balance Sheet</a>
        <a href="<?= PROOT; ?>FinancialReports/cashFlow" class="btn btn-sm btn-outline-primary"><i class="fas fa-arrows-turn-to-dots me-1"></i>Cash Flow</a>
        <a href="<?= PROOT; ?>TaxReturns" class="btn btn-sm btn-outline-primary"><i class="fas fa-file-invoice me-1"></i>Tax Returns</a>
        <a href="<?= PROOT; ?>BankRecon" class="btn btn-sm btn-outline-primary"><i class="fas fa-cash-register me-1"></i>Bank Recon</a>
        <a href="<?= PROOT; ?>Payroll" class="btn btn-sm btn-outline-primary"><i class="fas fa-money-check-alt me-1"></i>Payroll</a>
      </div>
    </div></div>
  </div>
</div>

<?php $this->end(); $this->start('section_js'); ?>
<script>
document.addEventListener('DOMContentLoaded', function () {
  new PacificChart('#c-funnel', 'bar',
    <?= json_encode(array_merge($this->data['charts']['funnel'] ?? [], ['horizontal' => true, 'distributed' => true, 'colors' => ['#2626F5','#F59E0B','#0E9F6E']])); ?>);
  new PacificChart('#c-cash',   'area',
    <?= json_encode(array_merge($this->data['charts']['cash']   ?? [], ['tzs' => true])); ?>);
  new PacificChart('#c-flows',  'bar',
    <?= json_encode(array_merge($this->data['charts']['flows']  ?? [], ['tzs' => true, 'colors' => ['#0E9F6E','#DC2626']])); ?>);
  new PacificChart('#c-mix',    'donut',
    <?= json_encode(array_merge($this->data['charts']['mix']    ?? [], ['tzs' => true, 'colors' => 'penta'])); ?>);
});
</script>
<?php $this->end(); ?>
