<?php $__env->startSection('title'); ?>
Notícias
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content-header'); ?>
Notícias 
<small>
    <?php echo $action; ?>

</small>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('breadcrumb'); ?>
<li>
    <a href="<?php echo route('admin.news.index'); ?>">
        Notícias
    </a>
</li>
<li class="active">
    <?php echo $action; ?>

</li>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('styles'); ?>
<?php echo HTML::style('assets/vendor/jasny-bootstrap/dist/css/jasny-bootstrap.min.css'); ?>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('plugins'); ?>
<?php echo HTML::script('assets/vendor/jasny-bootstrap/dist/js/jasny-bootstrap.min.js'); ?>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
<div class="row">
    <div class="col-xs-12">
        <div class="box box-solid">

            <?php echo Form::model($news, $formOptions); ?>

            <div class="box-body">
                <div class="row">

                    <div class="col-sm-12 col-md-8 col-lg-9">
                        <div class="form-group is-required">
                            <?php echo Form::label('title', 'Título'); ?>

                            <?php echo Form::text('title', null, array('class' =>'form-control', 'required' => true)); ?>

                        </div>
                        <div class="form-group is-required">
                            <?php echo Form::label('content', 'Conteúdo da Notícia'); ?>

                            <?php echo Form::textarea('content', null, array('class' =>'form-control ckeditor', 'required' => true)); ?>

                        </div>
                    </div>
                    <div class="col-sm-12 col-md-4 col-lg-3">
                        <div class="form-group">
                            <?php echo Form::label('date', 'Data da Notícia'); ?>

                            <div class="input-group">
                                <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                <?php if($news->date): ?>
                                <?php echo Form::text('date', date('Y-m-d', strtotime($news->date)), array('class' =>'form-control datepicker', 'required' => true)); ?>

                                <?php else: ?>
                                <?php echo Form::text('date', date('Y-m-d'), array('class' =>'form-control datepicker', 'required' => true)); ?>

                                <?php endif; ?>
                            </div>
                        </div>

                        <div class="form-group">
                            <?php echo Form::label('image', 'Imagem'); ?>

                            <div class="clearfix"></div>
                                <?php if($news->fileurl): ?>
                                <div class="fileinput fileinput-exists width-100" data-provides="fileinput">
                                <?php else: ?>
                                <div class="fileinput fileinput-new width-100" data-provides="fileinput">
                                <?php endif; ?>
                                    <div class="fileinput-preview thumbnail width-100" data-trigger="fileinput">
                                        <?php if($news->fileurl): ?>
                                        <img src="<?php echo asset($news->fileurl); ?>">
                                        <?php endif; ?>
                                    </div>
                                    <div>
                                        <span class="btn btn-default btn-file">
                                            <span class="fileinput-new">Selecionar</span>
                                            <span class="fileinput-exists btn-change-photo">Alterar</span>
                                            <input type="file" name="image" accept="image/*">
                                        </span>
                                        <a href="#" class="btn btn-danger btn-remove-photo fileinput-exists" data-dismiss="fileinput">Anular</a>
                                        <a href="#" class="btn btn-default btn-reset-photo hidden">Repôr Original</a>
                                    </div>
                                    <?php echo Form::hidden('delete_photo', 0); ?>

                                    <?php if($news->fileurl): ?>
                                    <?php echo Form::hidden('original_fileurl', asset($news->fileurl)); ?>

                                    <?php endif; ?>
                                </div>
                            </div>
                        </div>
                        
                    </div>
                    <div class="row">
                        <div class="col-sm-9">
                            <div class="form-group">
                                <?php echo Form::label('documents', 'Anexar os seguintes documentos'); ?>

                                <?php echo Form::select('documents[]', $documents, @$selectedDocuments, array('class' =>'form-control select2', 'multiple'=>'true')); ?>

                            </div>
                        </div>
                        <div class="col-sm-3">
                            <div class="form-group">
                                <?php echo Form::label('highlight', 'Destaque'); ?>

                                <div class="checkbox">
                                    <label style="padding: 0 !important">
                                        <?php echo Form::checkbox('highlight', 1, false);; ?>

                                        Colocar notícia em destaque
                                    </label>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-sm-12">
                            <?php echo Form::submit('Gravar', array('class' => 'btn btn-primary' )); ?>

                        </div>
                    </div>
                </div>
                <?php echo Form::close(); ?>

            </div>
        </div>  
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('scripts'); ?>
<script>
    //remove photo
    $('.btn-remove-photo').on('click', function(){
        if($('input[name=original_fileurl]').length > 0) {
            $('.btn-reset-photo').removeClass('hidden');
            $('input[name=delete_photo]').val(1);
        }
    });
    
    //reset original photo
    $('.btn-reset-photo').on('click', function(e){
        e.preventDefault();
        $(this).addClass('hidden');
        $('input[name=delete_photo]').val('');
        $('.fileinput-preview').html('<img src="' + $('input[name=original_fileurl]').val() + '">');
        $('.fileinput').removeClass('fileinput-new').addClass('fileinput-exists');
        $('input[name=image]').val('');
    })
</script>
<?php $__env->stopSection(); ?>

