<?= $this->extend('frontend/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 Service</h1>
      </div>
    </div>
  </div>
</section>

<section class="content">
  <div class="container-fluid">
    <?php echo form_open('shopkeeper/services/save', ['class' => 'form-validate', 'autocomplete' => 'off']); ?>
      <div class="card">
        <div class="card-body">
          <div class="form-group">
            <label>Name</label>
            <input type="text" class="form-control" name="name" required autofocus>
          </div>
          <div class="form-row">
            <div class="form-group col-md-6">
              <label>Category</label>
              <select name="category_id" class="form-control select2">
                <option value="">None</option>
                <?php foreach ($categories as $c): ?>
                  <option value="<?php echo $c->id ?>"><?php echo esc($c->name) ?></option>
                <?php endforeach ?>
              </select>
            </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 class="form-control" name="status">
              <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('shopkeeper/services') ?>" 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(); ?>
  </div>
</section>

<?= $this->endSection() ?>
<?= $this->section('js') ?>
<script>
  $(document).ready(function() {
    $('.form-validate').validate();
    $('.select2').select2();
  });
</script>
<?= $this->endSection() ?>

