<?= $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>Shops</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">Shops</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('shops_add')): ?>
          <a href="<?php echo url('shops/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>Name</th>
            <th>Slug</th>
            <th>Subscription</th>
            <th width="170">Subscription Start</th>
            <th width="170">Subscription End</th>
            <th width="110">Subscription Status</th>
            <th width="90">Status</th>
            <th width="140">Action</th>
          </tr>
        </thead>
        <tbody>
          <?php foreach ($shops as $row): ?>
            <tr>
              <td><?php echo $row->id ?></td>
              <td><?php echo esc($row->name) ?></td>
              <td><?php echo esc($row->slug) ?></td>
              <td><?php echo esc($row->subscription_title ?? '-') ?></td>
              <td><?php echo esc($row->subscription_start_at ?? '-') ?></td>
              <td><?php echo esc($row->subscription_end_at ?? '-') ?></td>
              <td><?php echo esc($row->subscription_status ?? '-') ?></td>
              <td><?php echo $row->status ? 'Active' : 'Inactive' ?></td>
              <td>
                <?php if (hasPermissions('shops_view')): ?>
                  <a href="<?php echo url('shops/view/'.$row->id) ?>" class="btn btn-sm btn-default" data-toggle="tooltip" title="View"><i class="fas fa-eye"></i></a>
                <?php endif ?>
                <?php if (hasPermissions('shops_edit')): ?>
                  <a href="<?php echo url('shops/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('shops_delete')): ?>
                  <a href="<?php echo url('shops/delete/'.$row->id) ?>" class="btn btn-sm btn-danger" onclick="return confirm('Delete this shop?')" 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() ?>

