<script>
    function type() {
        var $type = $("#type");
        var $coin = $(".coin");
        if ($type.val() === "physicist") {
            $coin.hide();
        } else {
            $coin.show();
        }
    }

    $(function () {
        type();

        $("#type").change(function () {
            type();
        });

        $(".draw").click(function (e) {
            var $character = $("#character");
            $.get(prefix + "prize-draw/random-character", function (character) {
                $character.val(character);
            });

            e.preventDefault();
        });
    })
</script>

<section class="content-header">
    <h1><?= __('Draw for online users') ?></h1>
</section>

<section class="content">

    <div class="box box-default">
        <form data-ajax class="form-focus" action="<?= admin_url_to('/prize-draw') ?>" 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><?= __('Draw') ?></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="type"><?= __('Type') ?> <span class="required">*</span></label>
                                        <select class="form-control" id="type" name="type">
                                            <option value="physicist"><?= __('Physicist') ?></option>
                                            <option value="coin" selected><?= __('Coin') ?></option>
                                        </select>
                                    </div>
                                </div>

                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label class="control-label" for="character"><?= __('Character') ?> <span class="required">*</span></label>
                                        <div>
                                            <input style="width:70%;display:inline-block" class="form-control" type="text" readonly value="" name="character" id="character" />
                                            <a class="draw" href=""><?= __('Prize Draw') ?></a>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="control-label" for="message"><?= __('Message') ?> <span class="required">*</span></label>
                                <textarea class="form-control" id="message" style="height:200px" name="message"></textarea>
                            </div>

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

                                <div class="col-md-6">
                                    <div class="form-group coin" style="display:none">
                                        <label class="control-label" for="amount"><?= __('Amount') ?> <span class="required">*</span></label>
                                        <input class="form-control" type="text" value="" 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="<?= __('Send') ?>" />
                    </div>
                </div>
            </div>
        </form>
    </div>
</section>