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

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

<section class="content">
    <div class="box box-default">
        <form data-ajax data-upload class="form-action" action="<?= admin_url_to('/vote-reward/providers/edit/' . $provider['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><?= __('Provider') ?></h5>
                        </div>

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

                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label class="control-label" for="delay"><?= __('Delay in hours') ?></label>
                                        <input class="form-control" value="<?= $provider['delay'] ?>" type="text" name="delay" id="delay" />
                                    </div>
                                </div>

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

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

                            <div class="row">
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label class="control-label" for="api"><?= __('API') ?></label>
                                        <select class="form-control" name="api" id="api">
                                            <option value=""></option>
                                            <?php foreach (vote_reward_apis() as $v => $api): ?>
                                                <option<?= $provider['api'] === $v ? ' selected' : '' ?> value="<?= $v ?>"><?= $api ?></option>
                                            <?php endforeach ?>
                                        </select>
                                    </div>
                                </div>

                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label class="control-label" for="image"><?= __('Image') ?></label>
                                        <input data-upload-field class="form-control" type="file" name="image" />
                                    </div>

                                </div>
                            </div>

                            <div class="row">
                                <div class="col-md-6">
                                    <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<?= $provider['coin'] === $coin['id'] ? ' selected' : '' ?> value="<?= $coin['id'] ?>"><?= $coin['name'] ?></option>
                                            <?php endforeach ?>
                                        </select>
                                    </div>
                                </div>

                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label class="control-label" for="amount"><?= __('Amount') ?> <span class="required">*</span></label>
                                        <input class="form-control" value="<?= $provider['amount'] ?>" type="text" name="amount" id="amount" />
                                    </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>
</section>