<?= $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>Add Product</h1>
      </div>
    </div>
  </div>
</section>

<section class="content">
<?php echo form_open('rewarderProducts/save', ['class' => 'form-validate', 'autocomplete' => 'off', 'enctype' => 'multipart/form-data']); ?>
  <div class="card">
    <div class="card-body">
      <div class="form-group">
        <label>Shop</label>
        <select id="shop_id" name="shop_id" class="form-control select2" required>
          <option value="">Select</option>
          <?php foreach ($shops as $s): ?>
            <option value="<?php echo $s->id ?>"><?php echo esc($s->name) ?></option>
          <?php endforeach ?>
        </select>
      </div>
      <div class="form-group">
        <label>Category</label>
        <select id="category_id" name="category_id" class="form-control select2">
          <option value="">None</option>
          <?php foreach ($categories as $c): ?>
            <option value="<?php echo $c->id ?>" data-shop="<?php echo $c->shop_id ?>"><?php echo esc($c->name) ?></option>
          <?php endforeach ?>
        </select>
      </div>
      <div class="form-group">
        <label>Name</label>
        <input type="text" class="form-control" name="name" required autofocus>
      </div>
      <div class="form-group">
        <label>Image</label>
        <input type="file" class="form-control" name="image" accept="image/*">
      </div>
      <div class="form-row">
        <div class="form-group col-md-6">
          <label>SKU</label>
          <input type="text" class="form-control" name="sku">
        </div>
        <div class="form-group col-md-6">
          <label>Price</label>
          <input type="number" step="0.01" class="form-control" name="price" value="0">
        </div>
      </div>
      <div class="form-group">
        <label>Status</label>
        <select name="status" class="form-control">
          <option value="1" selected>Active</option>
          <option value="0">Inactive</option>
        </select>
      </div>
    </div>
    <div class="card-footer">
      <div class="row">
        <div class="col"><a href="<?php echo url('rewarderProducts') ?>" class="btn btn-flat btn-danger" onclick="return confirm('Leave without saving?')">Cancel</a></div>
        <div class="col text-right"><button type="submit" class="btn btn-flat btn-primary">Save</button></div>
      </div>
    </div>
  </div>
<?php echo form_close(); ?>
</section>

<?= $this->endSection() ?>
<?= $this->section('js') ?>
<?= $this->include('admin/rewarder/products/_form_js') ?>
<?= $this->endSection() ?>

