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

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

<section class="content">
    <div class="box box-default">
        <form data-ajax class="form-focus" method="post" action="<?= admin_url_to('/characters/edit/' . $character['name']) ?>">
            <?= 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><?= __('Character') ?></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="character-name"><?= __('Name') ?> <span class="required">*</span></label>
                                        <input class="form-control" type="text" value="<?= $character['name'] ?>" name="name" id="character-name" />
                                    </div>
                                </div>

                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label class="control-label"><?= __('Account') ?></label>
                                        <p class="form-control-static"><a data-ajax href="<?= admin_url_to('/accounts/edit/' . $character['username']) ?>"><?= $character['username'] ?></a></p>
                                    </div>
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label class="control-label" for="character-level"><?= __('Level') ?> <span class="required">*</span></label>
                                        <input class="form-control" type="text" value="<?= $character['level'] ?>" name="level" id="character-level" />
                                    </div>
                                </div>

                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label class="control-label" for="character-experience"><?= __('Experience') ?></label>
                                        <input class="form-control" type="text" value="<?= $character['experience'] ?>" name="experience" id="character-experience" />
                                    </div>
                                </div>

                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label class="control-label" for="character-points"><?= __('Points') ?></label>
                                        <input class="form-control" type="text" value="<?= $character['points'] ?>" name="points" id="character-points" />
                                    </div>
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label class="control-label" for="character-class"><?= __('Class') ?></label>
                                        <select class="form-control" name="class" id="character-class">
                                            <?php foreach (config('characters.classes', []) as $code => $class): ?>
                                                <option value="<?= $code ?>"<?= $character['class'] == $code ? ' selected="selected"' : '' ?>><?= $class['name'] ?></option>
                                            <?php endforeach ?>
                                        </select>
                                    </div>
                                </div>

                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label class="control-label" for="character-code"><?= __('Type') ?></label>
                                        <select class="form-control" name="code" id="character-code">
                                            <?php foreach (config('characters.code_types', []) as $code => $name): ?>
                                                <option value="<?= $code ?>"<?= $character['code'] == $code ? ' selected="selected"' : '' ?>><?= $name ?></option>
                                            <?php endforeach ?>
                                        </select>
                                    </div>
                                </div>

                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label class="control-label" for="character-pk"><?= __('PK Level') ?></label>
                                        <select class="form-control" name="pk" id="character-pk">
                                            <?php foreach (config('characters.pk_levels', []) as $code => $name): ?>
                                                <option value="<?= $code ?>"<?= $character['pkLevel'] == $code ? ' selected="selected"' : '' ?>><?= $name ?></option>
                                            <?php endforeach ?>
                                        </select>
                                    </div>
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label class="control-label" for="character-map"><?= __('Map') ?></label>
                                        <select class="form-control" name="map" id="character-map">
                                            <?php foreach (config('maps', []) as $code => $map): ?>
                                                <option value="<?= $code ?>"<?= $character['map'] == $code ? ' selected="selected"' : '' ?>><?= $map['name'] ?></option>
                                            <?php endforeach ?>
                                        </select>
                                    </div>
                                </div>

                                <div class="col-md-3">
                                    <div class="form-group">
                                        <label class="control-label" for="character-x"><?= __('Coordinate') ?> X <span class="required">*</span></label>
                                        <input class="form-control" type="text" value="<?= $character['positionX'] ?>" name="x" id="character-x" />
                                    </div>
                                </div>

                                <div class="col-md-3">
                                    <div class="form-group">
                                        <label class="control-label" for="character-x"><?= __('Coordinate') ?> Y <span class="required">*</span></label>
                                        <input class="form-control" type="text" value="<?= $character['positionY'] ?>" name="y" id="character-y" />
                                    </div>
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label class="control-label" for="character-strength"><?= __('Strength') ?></label>
                                        <input class="form-control" type="text" value="<?= $character['strength'] ?>" name="strength" id="character-strength" />
                                    </div>
                                </div>

                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label class="control-label" for="character-agility"><?= __('Agility') ?></label>
                                        <input class="form-control" type="text" value="<?= $character['agility'] ?>" name="agility" id="character-agility" />
                                    </div>
                                </div>

                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label class="control-label" for="character-energy"><?= __('Energy') ?></label>
                                        <input class="form-control" type="text" value="<?= $character['energy'] ?>" name="energy" id="character-energy" />
                                    </div>
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label class="control-label" for="character-vitality"><?= __('Vitality') ?></label>
                                        <input class="form-control" type="text" value="<?= $character['vitality'] ?>" name="vitality" id="character-vitality" />
                                    </div>
                                </div>

                                <?php if (isset($character['command'])): ?>
                                    <div class="col-md-4">
                                        <div class="form-group">
                                            <label class="control-label" for="character-command"><?= __('Command') ?></label>
                                            <input class="form-control" type="text" value="<?= $character['command'] ?>" name="command" id="character-command" />
                                        </div>
                                    </div>
                                <?php endif ?>
                            </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><?= __('Money') ?></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="character-money"><?= __('Zen') ?></label>
                                        <input class="form-control" type="text" value="<?= $character['money'] ?>" name="money" id="character-money" />
                                    </div>
                                </div>


                                <?php if (isset($character['ruud'])): ?>
                                    <div class="col-md-6">
                                        <div class="form-group">
                                            <label class="control-label" for="character-ruud"><?= __('Ruud') ?></label>
                                            <input class="form-control" type="text" value="<?= $character['ruud'] ?>" name="ruud" id="character-ruud" />
                                        </div>
                                    </div>
                                <?php endif ?>
                            </div>
                        </div>
                    </div>
                </div>

                <?php if (config('columns.resets') || config('columns.master_resets')): ?>
                    <div class="section">
                        <div class="row">
                            <div class="col-lg-3 col-md-3 col-sm-4 col-xs-12">
                                <h5><?= __('Resets') ?></h5>
                            </div>

                            <div class="col-lg-9 col-md-9 col-sm-8 col-xs-12">
                                <div class="row">
                                    <?php if (config('columns.resets')): ?>
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="control-label" for="character-resets"><?= __('Resets') ?></label>
                                                <input class="form-control" type="text" value="<?= $character['resets'] ?>" name="resets" id="character-resets" />
                                            </div>
                                        </div>
                                    <?php endif ?>

                                    <?php if (config('columns.master_resets')): ?>
                                        <div class="col-md-6">
                                            <div class="form-group">
                                                <label class="control-label" for="character-master-resets"><?= __('Master Resets') ?></label>
                                                <input class="form-control" type="text" value="<?= $character['masterResets'] ?>" name="master_resets" id="character-master-resets" />
                                            </div>
                                        </div>
                                    <?php endif ?>
                                </div>
                            </div>
                        </div>
                    </div>
                <?php endif ?>

                <?php notify('admin.characters.edit.render', $character) ?>
            </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>
