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

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

<section class="content">
    <div class="box box-default">
        <form data-ajax class="form-action" action="<?= admin_url_to('/raffles/edit/' . $raffle['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><?= __('Raffle') ?></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="<?= $raffle['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"<?= $raffle['active'] ? ' checked' : '' ?> type="checkbox" id="active" value="1" name="active" />
                                        </div>
                                    </div>
                                </div>
                            </div>

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

                            <div class="row">
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label class="control-label" for="type"><?= __('Type') ?> <span class="required">*</span></label>
                                        <select class="form-control" type="text" name="type" id="type">
                                            <option value=""></option>
                                            <option<?= $raffle['type'] == 1 ? ' selected' : '' ?> value="1"><?= __('Reward') ?></option>
                                            <option<?= $raffle['type'] == 2 ? ' selected' : '' ?> value="2"><?= __('Custom') ?></option>
                                        </select>
                                    </div>
                                </div>

                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label class="control-label" for="total-numbers"><?= __('Total numbers') ?> <span class="required">*</span></label>
                                        <input class="form-control" type="text" value="<?= $raffle['total_numbers'] ?>" name="total_numbers" id="total-numbers" />
                                    </div>
                                </div>

                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label class="control-label" for="price"><?= __('Price') ?> <span class="required">*</span></label>
                                        <input class="form-control money" type="text" value="<?= util('Number')->currencyWithoutSymbol($raffle['price']) ?>" name="price" id="price" />
                                    </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><?= __('Rewards') ?></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="vip-type"><?= __('Vip type') ?></label>
                                        <select class="form-control" id="vip-type" name="vip_type">
                                            <option value=""></option>
                                            <?php foreach (config('vip.types', []) as $key => $value): ?>
                                                <option<?= $raffle['vip_type'] == $key ? ' selected' : '' ?> value="<?= $key ?>"><?= $value ?></option>
                                            <?php endforeach ?>
                                        </select>
                                    </div>
                                </div>

                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label class="control-label" for="vip-days"><?= __('Vip days') ?></label>
                                        <input class="form-control" type="text" value="<?= $raffle['vip_days'] ?>" id="vip_days" name="vip_days" />
                                    </div>
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-md-4">
                                    <label class="control-label" for="credits"><?= __('Credits') ?></label>
                                    <input class="form-control money" type="text" value="<?= util('Number')->currencyWithoutSymbol($raffle['credits']) ?>" name="credits" id="credits" />
                                </div>

                                <?php foreach ($coins as $coin): ?>
                                    <div class="col-md-4">
                                        <div class="form-group">
                                            <label class="control-label" for="coin-<?= $coin['column'] ?>"><?= $coin['name'] ?></label>
                                            <input class="form-control" value="<?= isset($raffle['coins'][$coin['id']]) ? $raffle['coins'][$coin['id']] : '' ?>" type="text" id="coin-<?= $coin['column'] ?>" name="coins[<?= $coin['id'] ?>]" />
                                        </div>
                                    </div>
                                <?php endforeach ?>
                            </div>

                            <div class="form-group">
                                <label class="control-label" for="custom"><?= __('Custom') ?></label>
                                <textarea rows="6" class="form-control" id="custom" name="custom"><?= $raffle['custom'] ?></textarea>
                            </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>