<?= $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>Subscriptions</h1>
      </div>
      <div class="col-sm-6">
        <ol class="breadcrumb float-sm-right">
          <li class="breadcrumb-item"><a href="<?php echo url('/') ?>">Home</a></li>
          <li class="breadcrumb-item active">Subscriptions</li>
        </ol>
      </div>
    </div>
  </div>
</section>

<section class="content">
  <div class="card">
    <div class="card-header with-border">
      <h3 class="card-title">List</h3>
      <div class="card-tools pull-right">
        <?php if (hasPermissions('subscriptions_add')): ?>
          <a href="<?php echo url('subscriptions/add') ?>" class="btn btn-primary btn-sm"><i class="fa fa-plus pr-1"></i> Add</a>
        <?php endif ?>
      </div>
    </div>
    <div class="card-body">
      <table id="example1" class="table table-bordered table-striped">
        <thead>
          <tr>
            <th width="60">ID</th>
            <th>Title</th>
            <th width="120">Price</th>
            <th width="140">Duration (months)</th>
            <th width="90">Status</th>
            <th width="140">Action</th>
          </tr>
        </thead>
        <tbody>
          <?php foreach ($subscriptions as $row): ?>
            <tr>
              <td><?php echo $row->id ?></td>
              <td><?php echo esc($row->title) ?></td>
              <td><?php echo esc($row->price) ?></td>
              <td><?php echo esc($row->duration_months) ?></td>
              <td><?php echo $row->status ? 'Active' : 'Inactive' ?></td>
              <td>
                <?php if (hasPermissions('subscriptions_edit')): ?>
                  <a href="<?php echo url('subscriptions/edit/'.$row->id) ?>" class="btn btn-sm btn-default" data-toggle="tooltip" title="Edit"><i class="fas fa-edit"></i></a>
                <?php endif ?>
                <?php if (hasPermissions('subscriptions_delete')): ?>
                  <a href="<?php echo url('subscriptions/delete/'.$row->id) ?>" class="btn btn-sm btn-danger" onclick="return confirm('Delete this subscription?')" data-toggle="tooltip" title="Delete"><i class="fas fa-trash"></i></a>
                <?php endif ?>
              </td>
            </tr>
          <?php endforeach ?>
        </tbody>
      </table>
    </div>
  </div>
</section>

<?= $this->endSection() ?>

