<section class="content-header">
    <h1><?= __('Edit category') ?></h1>

    <div class="actions">
        <a data-ajax class="btn btn-default btn-sm" href="<?= admin_url_to('/webshop/categories?shop_id=' . $category['shop_id']) ?>"><?= __('List') ?></a>
    </div>
</section>

<section class="content">
    <div class="nav-tabs-custom">
        <ul class="nav nav-tabs">
            <li><a data-ajax href="<?= admin_url_to('/webshop/shops/edit/' . $category['shop_id']) ?>"><?= __('Shop') ?></a></li>
            <li class="active"><a data-ajax href="<?= admin_url_to('/webshop/categories?shop_id=' . $category['shop_id']) ?>"><?= __('Categories') ?></a></li>
        </ul>

        <div class="tab-content" style="padding:0">
            <form data-ajax class="form-focus" action="<?= admin_url_to('/webshop/categories/edit/' . $category['id']) ?>" method="post">
                <?= csrf_field() ?>

                <div class="box-body">
                    <div class="section">
                        <div class="row">
                            <div class="col-lg-3 col-md-3 col-sm-4 col-xs-12">
                                <h5><?= __('Category') ?></h5>
                            </div>

                            <div class="col-lg-9 col-md-9 col-sm-8 col-xs-12">
                                <div class="row">
                                    <div class="col-md-10">
                                        <div class="form-group">
                                            <label class="control-label" for="name"><?= __('Name') ?> <span class="required">*</span></label>
                                            <input class="form-control" value="<?= $category['name'] ?>" type="text" name="name" id="name" />
                                        </div>
                                    </div>

                                    <div class="col-md-2">
                                        <div class="form-group">
                                            <label class="control-label" for="active"><?= __('Active') ?></label>
                                            <div>
                                                <input class="form-control toggle"<?= $category['active'] ? ' checked' : '' ?> type="checkbox" id="active" value="1" name="active" />
                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class="control-label" for="slug"><?= __('URL') ?></label>
                                    <input class="form-control" value="<?= $category['slug'] ?>" type="text" name="slug" id="slug" />
                                </div>

                                <div class="row">
                                    <div class="col-md-6">
                                        <div class="form-group">
                                            <label class="control-label" for="type"><?= __('Type') ?></label>
                                            <select class="form-control" name="type" id="type">
                                                <option value=""></option>
                                                <?php foreach ($types as $type): ?>
                                                    <option<?= $category['type'] === strtolower($type) ? ' selected="selected"' : '' ?> value="<?= strtolower($type) ?>"><?= $type ?></option>
                                                <?php endforeach ?>
                                            </select>
                                        </div>
                                    </div>

                                    <div class="col-md-6">
                                        <div class="form-group">
                                            <label class="control-label" for="parent-id"><?= __('Parent category') ?></label>
                                            <select class="form-control" name="parent_id" id="parent-id">
                                                <option value=""></option>
                                                <?php foreach ($categories as $cat): ?>
                                                    <option<?= $cat['id'] == $category['parent_id'] ? ' selected' : '' ?> value="<?= $cat['id'] ?>"><?= $cat['name'] ?></option>
                                                <?php endforeach ?>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="box-footer">
                    <div class="row">
                        <div class="col-sm-offset-3" style="padding-left:15px">
                            <input type="submit" class="btn btn-primary" value="<?= __('Save') ?>" />
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</section>