<?php
$input_title = array(
    'name' => 'title',
    'type' => 'text',
    'value' => isset($title) ? $title : $contest[0]['title'],
    'placeholder' => '',
    'class' => '',
    'style' => 'width: 100%',
    'min' => 1,
    'max' => 50
);
$input_single = array(
    'name' => 'single',
    'type' => 'text',
    'value' => isset($date_limit) ? $date_limit : $contest[0]['name_single'],
    'placeholder' => '',
    'class' => '',
    'style' => 'width: 100%',
    'min' => 1,
    'max' => 50
);
$input_artist = array(
    'name' => 'artist',
    'type' => 'text',
    'value' => isset($artist) ? $artist : ($contest[0]['userid'] == 0) ? $contest[0]['artist'] : $contest[0]['clear_artists'],
    'placeholder' => '',
    'class' => '',
    'style' => 'width: 100%',
);

?>
<div class="row">
    <div class="widget-box">
        <div class="widget-header">
            <p class="widget-title">Thêm mới nhóm quản trị</p>
        </div>
        <div class="widget-body">
            <div class="widget-main">
                <?php
                $attributes = array('class' => 'form-horizontal', 'id' => 'myform');
                echo form_open(base_url().'backend/cmsContest/editContest/'.$contest[0]['id'], $attributes);
                ?>
                <div class="form-group">
                    <label class="col-lg-3"></label>
                    <div class="col-lg-3">
                        <input type="hidden" name="id" value="<?php echo $contest[0]['id']; ?>" />
                        <?php
                        if(validation_errors()){echo form_error('id', '<div class="error">', '</div>');}
                        ?>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-lg-3">Tên bài hát (*)</label>
                    <div class="col-lg-3">
                        <?php
                        echo form_input($input_title);
                        if(validation_errors()){echo form_error('title', '<div class="error">', '</div>');}
                        ?>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-lg-3">Tên ca sĩ (*)</label>
                    <div class="col-lg-3">
                        <?php
                        echo form_input($input_single);
                        if(validation_errors()){echo form_error('date_limit', '<div class="error">', '</div>');}
                        ?>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-lg-3">Tên nhạc sĩ (*)</label>
                    <div class="col-lg-3">
                        <?php
                        echo form_input($input_artist);
                        if(validation_errors()){echo form_error('date_from', '<div class="error">', '</div>');}
                        ?>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-lg-3">Tên nhạc sĩ (*)</label>
                    <div class="col-lg-3">
                        <select id='form-field-select-3' style='width: 200px;' class="chosen-select form-control"
                            data-placeholder="Choose a State...">
                            <?php foreach ($list_single as $single): ?>
                            <option value="<?php echo $single['id']; ?>"
                                <?php echo ($single['id'] == $contest[0]['id_single']) ? 'selected': ''; ?>>
                                <?php echo $single['name']; ?></option>
                            <?php endforeach; ?>
                        </select>
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-lg-3">
                        <a href="<?php echo base_url().'backend/cmsSetting/listGroup'?>"
                            onclick="return confirm('Bạn có chắc chắn muốn quay lại Danh sách không?')">
                            <button type="button" class="btn btn-sm btn-default">
                                <i class="ace-icon fa fa-arrow-left"></i>Quay lại
                            </button>
                        </a>
                    </div>
                    <div class="col-lg-4">
                        <button class="btn btn-sm btn-primary" type="submit" name="btnSave">
                            <i class="ace-icon fa fa-check bigger-110"></i>Lưu lại
                        </button>
                        <button class="btn btn-sm" type="reset">
                            <i class="ace-icon fa fa-undo bigger-110"></i>Xóa form
                        </button>
                    </div>
                </div>
                <?php echo form_close(); ?>
            </div>
        </div>
    </div>
</div><!-- /.row -->
<script>
$(document).ready(function() {
        $('.chosen-select').chosen({
            allow_single_deselect: true
        });
        $(window)
            .off('resize.chosen')
            .on('resize.chosen', function() {
                $('.chosen-select').each(function() {
                    var $this = $(this);
                    $this.next().css({
                        'width': $this.parent().width()
                    });
                })
            }).trigger('resize.chosen');
        //resize chosen on sidebar collapse/expand
        $(document).on('settings.ace.chosen', function(e, event_name, event_val) {
            if (event_name != 'sidebar_collapsed') return;
            $('.chosen-select').each(function() {
                var $this = $(this);
                $this.next().css({
                    'width': $this.parent().width()
                });
            })
        });
});
</script>