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

    <div class="actions">
        <a data-ajax class="btn btn-default btn-sm" href="<?= admin_url_to('/webshop/shops') ?>"><?= __('List') ?></a>
    </div>
</section>

<section class="content">

    <div class="nav-tabs-custom">
        <ul class="nav nav-tabs">
            <li class="active"><a href="#"><?= __('Shop') ?></a></li>
            <li><a data-ajax href="<?= admin_url_to('/webshop/categories?shop_id=' . $shop['id']) ?>"><?= __('Categories') ?></a></li>
        </ul>
        <div class="tab-content" style="padding:0">
            <form data-ajax class="form-focus" action="<?= admin_url_to('/webshop/shops/edit/' . $shop['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><?= __('Shop') ?></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="<?= $shop['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"<?= $shop['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="<?= $shop['slug'] ?>" type="text" name="slug" id="slug" />
                                </div>

                                <div class="form-group">
                                    <label class="control-label" for="description"><?= __('Description') ?></label>
                                    <textarea class="form-control" name="description" id="description"><?= $shop['description'] ?></textarea>
                                </div>

                                <div class="row">
                                    <div class="col-md-4">
                                        <div class="form-group">
                                            <label class="control-label" for="coin"><?= __('Coin') ?> <span class="required">*</span></label>
                                            <select class="form-control" name="coin" id="coin">
                                                <option value=""></option>
                                                <?php foreach (config('coins', []) as $coin): ?>
                                                    <option<?= $shop['coin'] == $coin['id'] ? ' selected' : '' ?> value="<?= $coin['id'] ?>"><?= $coin['name'] ?></option>
                                                <?php endforeach ?>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

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

                            <div class="col-lg-9 col-md-9 col-sm-8 col-xs-12">
                                <div class="row">
                                    <div class="col-md-4">
                                        <div class="form-group">
                                            <label class="control-label" for="max-level"><?= __('Item max level') ?></label>
                                            <select class="form-control" name="max_level" id="max-level">
                                                <?php for ($i = 0; $i <= config('item.max_level', 15); $i++): ?>
                                                    <option<?= $i == $shop['max_level'] ? ' selected="selected"' : '' ?> value="<?= $i ?>">+<?= $i ?></option>
                                                <?php endfor ?>
                                            </select>
                                        </div>
                                    </div>

                                    <div class="col-md-4">
                                        <div class="form-group">
                                            <label class="control-label" for="max-option"><?= __('Item max option') ?></label>
                                            <select class="form-control" name="max_option" id="max-option">
                                                <?php for ($i = 0; $i <= config('item.max_option', 28); $i+=4): ?>
                                                    <option<?= $i == $shop['max_option'] ? ' selected="selected"' : '' ?> value="<?= $i ?>">+<?= $i ?></option>
                                                <?php endfor ?>
                                            </select>
                                        </div>
                                    </div>

                                    <div class="col-md-4">
                                        <div class="form-group">
                                            <label class="control-label" for="default-max-excellent"><?= __('Max excellent options') ?></label>
                                            <select class="form-control" name="default_max_excellent" id="default-max-excellent">
                                                <option value=""></option>
                                                <?php for ($i = 1; $i <= 6; $i++): ?>
                                                    <option value="<?= $i ?>"<?= (int) $shop['default_max_excellent'] === $i ? ' selected' : '' ?>><?= $i ?></option>
                                                <?php endfor ?>
                                            </select>
                                        </div>
                                    </div>
                                </div>

                                <?php if ($version > 2): ?>
                                    <div class="row">
                                        <div class="col-md-4">
                                            <div class="form-group">
                                                <label class="control-label" for="allow-sockets"><?= __('Allow sockets') ?></label>
                                                <select class="form-control" name="allow_sockets" id="allow-sockets">
                                                    <option value=""></option>
                                                    <option value="1"<?= $shop['allow_sockets'] == 1 ? ' selected' : '' ?>><?= __('All') ?></option>
                                                    <option value="2"<?= $shop['allow_sockets'] == 2 ? ' selected' : '' ?>><?= __('Only empty') ?></option>
                                                </select>
                                            </div>
                                        </div>

                                        <div class="col-md-4">
                                            <div class="form-group">
                                                <label class="control-label" for="default-max-sockets"><?= __('Max socket options') ?></label>
                                                <select class="form-control" name="default_max_sockets" id="default-max-sockets">
                                                    <option value=""></option>
                                                    <?php for ($i = 1; $i <= 5; $i++): ?>
                                                        <option value="<?= $i ?>"<?= (int) $shop['default_max_sockets'] === $i ? ' selected' : '' ?>><?= $i ?></option>
                                                    <?php endfor ?>
                                                </select>
                                            </div>
                                        </div>

                                        <div class="col-md-4">
                                            <div class="form-group">
                                                <label class="control-label" for="shops-unique-sockets"><?= __('Unique sockets') ?></label>
                                                <select class="form-control" name="unique_sockets" id="shops-unique-sockets">
                                                    <option value=""></option>
                                                    <option value="1"<?= $shop['unique_sockets'] == 1 ? ' selected' : '' ?>><?= __('Per code') ?></option>
                                                    <option value="2"<?= $shop['unique_sockets'] == 2 ? ' selected' : '' ?>><?= __('Per type') ?></option>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                <?php endif ?>
                            </div>
                        </div>
                    </div>

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

                            <div class="col-lg-9 col-md-9 col-sm-8 col-xs-12">
                                <div class="row">
                                    <div class="col-md-4">
                                        <div class="form-group">
                                            <label class="control-label" for="default-price-level"><?= __('Price for level') ?></label>
                                            <input class="form-control" type="text" value="<?= $shop['default_price_level'] ?>" name="default_price_level" id="default-price-level" />
                                        </div>
                                    </div>

                                    <div class="col-md-4">
                                        <div class="form-group">
                                            <label class="control-label" for="default-price-option"><?= __('Price for option') ?></label>
                                            <input class="form-control" type="text" value="<?= $shop['default_price_option'] ?>" name="default_price_option" id="default-price-option" />
                                        </div>
                                    </div>

                                    <div class="col-md-4">
                                        <div class="form-group">
                                            <label class="control-label" for="default-price-skill"><?= __('Price for skill') ?></label>
                                            <input class="form-control" type="text" value="<?= $shop['default_price_skill'] ?>" name="default_price_skill" id="default-price-skill" />
                                        </div>
                                    </div>
                                </div>

                                <div class="row">
                                    <div class="col-md-4">
                                        <div class="form-group">
                                            <label class="control-label" for="default-price-luck"><?= __('Price for luck') ?></label>
                                            <input class="form-control" type="text" value="<?= $shop['default_price_luck'] ?>" name="default_price_luck" id="shops-default-price-luck" />
                                        </div>
                                    </div>

                                    <div class="col-md-4">
                                        <div class="form-group">
                                            <label class="control-label" for="shops-default-price-excellent"><?= __('Price for excellent') ?></label>
                                            <input class="form-control" type="text" value="<?= $shop['default_price_excellent'] ?>" name="default_price_excellent" id="default-price-excellent" />
                                        </div>
                                    </div>

                                    <?php if ($version >= 1.1): ?>
                                        <div class="col-md-4">
                                            <div class="form-group">
                                                <label class="control-label" for="default-price-ancient"><?= __('Price for ancient') ?></label>
                                                <input class="form-control" type="text" value="<?= $shop['default_price_ancient'] ?>" name="default_price_ancient" id="default-price-ancient" />
                                            </div>
                                        </div>
                                    <?php endif ?>
                                </div>

                                <?php if ($version > 2): ?>
                                    <div class="row">
                                        <div class="col-md-4">
                                            <div class="form-group">
                                                <label class="control-label" for="default-price-harmony"><?= __('Price for harmony') ?></label>
                                                <input class="form-control" type="text" value="<?= $shop['default_price_harmony'] ?>" name="default_price_harmony" id="default-price-harmony" />
                                            </div>
                                        </div>

                                        <div class="col-md-4">
                                            <div class="form-group">
                                                <label class="control-label" for="default-price-refine"><?= __('Price for refine') ?></label>
                                                <input class="form-control" type="text" value="<?= $shop['default_price_refine'] ?>" name="default_price_refine" id="default-price-refine" />
                                            </div>
                                        </div>

                                        <div class="col-md-4">
                                            <div class="form-group">
                                                <label class="control-label" for="default-price-socket"><?= __('Price for socket') ?></label>
                                                <input class="form-control" type="text" value="<?= $shop['default_price_socket'] ?>" name="default_price_socket" id="default-price-socket" />
                                            </div>
                                        </div>
                                    </div>
                                <?php endif ?>
                            </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>