<?= $this->extend('admin/layout/default') ?>
<?= $this->section('content') ?>
<section class="content-header">
  <div class="container-fluid">
    <div class="row mb-2">
      <div class="col-sm-6">
        <h1>Subscription Receipt</h1>
      </div>
      <div class="col-sm-6">
        <ol class="breadcrumb float-sm-right">
          <li class="breadcrumb-item"><a href="<?= url('/') ?>">Home</a></li>
          <li class="breadcrumb-item"><a href="<?= url('shopSubscriptions') ?>">Shop Subscriptions</a></li>
          <li class="breadcrumb-item active">Receipt</li>
        </ol>
      </div>
    </div>
  </div>
</section>
<section class="content">
  <div class="card">
    <div class="card-body">
      <?php if ($row): ?>
        <div class="row">
          <div class="col-md-6">
            <p><strong>Shop:</strong> <?= esc($row->shop_name) ?></p>
            <p><strong>Subscription:</strong> <?= esc($row->subscription_title) ?></p>
            <p><strong>Period:</strong> <?= esc($row->start_at) ?> to <?= esc($row->end_at) ?></p>
          </div>
          <div class="col-md-6">
            <p><strong>Status:</strong> <?= esc($row->status) ?></p>
            <p><strong>Price Mode:</strong> <?= $row->tax_inclusive ? 'Tax Included' : 'Tax Added Separately' ?></p>
          </div>
        </div>
        <hr>
        <h4>Amount</h4>
        <table class="table">
          <tr>
            <th>Base Price</th>
            <td><?= number_format($row->base_price, 2) ?></td>
          </tr>
          <?php if (!empty($taxes)): ?>
            <tr>
              <th>Taxes</th>
              <td>
                <ul class="mb-0">
                  <?php foreach ($taxes as $t): ?>
                    <li>
                      <?= esc($t->name) ?> -
                      <?= $t->rate_type === 'PERCENT' ? number_format($t->rate, 2).'%' : number_format($t->rate, 2) ?>
                    </li>
                  <?php endforeach ?>
                </ul>
              </td>
            </tr>
          <?php endif ?>
          <tr>
            <th><?= $row->tax_inclusive ? 'Tax (Included)' : 'Tax (Added)' ?></th>
            <td><?= number_format($row->tax_total, 2) ?></td>
          </tr>
          <tr>
            <th>Total</th>
            <td><?= number_format($row->total_amount, 2) ?></td>
          </tr>
        </table>
      <?php else: ?>
        <div class="alert alert-danger">Record not found.</div>
      <?php endif ?>
    </div>
  </div>
</section>
<?= $this->endSection() ?>

