<?php $__env->startSection('content'); ?>
    <h1 class="page-title">
        <a class=" icon-action-undo" href="<?php echo e(url('bibliografia')); ?>" style="padding: 5px;"></a>
        Gestión de Bibliografía
    </h1>


    <?php echo e(Form::model($bibliografia, array('route' => array('bibliografia.editar', $bibliografia->id), 'class'=>'form-horizontal','enctype'=> 'multipart/form-data', 'id' => 'form-validation' ,'style'=>'padding: 5px 5px 5px 5px;', 'method' => 'POST'))); ?>

    <?php echo e(csrf_field()); ?>

    <?php echo e(Form::hidden('id')); ?>

    <div class="portlet light portlet-fit portlet-form bordered">
        <div class="portlet-title">
            <div class="caption">
                <span class="caption-subject sbold uppercase"> Edición de Bibliografía </span>
            </div>
        </div>
        <div class="portlet-body">
            <div class="col-xs-12" style="padding-bottom: 25px">
                <h4 class="page-head">
                    Datos Generales
                </h4>
            </div>
            <div class="Forum-ForumTopicList row" style="margin:20px">
                <div class="form-group row">
                    <div class="col-xs-3">
                        <label class = "caption-subject font-blue-secondary sbold">
                            Nombre
                        </label>
                    </div>
                    <div class="col-xs-9">
                        <?php echo Form::text('nombre', null, ['class' => 'form-control', 'required' => 'required']); ?>

                    </div>
                </div>
                <div class="form-group row">
                    <div class="col-xs-3">
                        <label class = "caption-subject font-blue-secondary sbold">
                            Materia
                        </label>
                    </div>
                    <div class="col-xs-9">
                        <?php echo Form::text('materia', null, ['class' => 'form-control', 'required' => 'required']); ?>

                    </div>
                </div>
                <div class="form-group row">
                    <div class="col-xs-3">
                        <label class = "caption-subject font-blue-secondary sbold">
                            Lugar de Publicación
                        </label>
                    </div>
                    <div class="col-xs-9">
                        <?php echo Form::text('ciudad_pais', null, ['class' => 'form-control', 'required' => 'required']); ?>

                    </div>
                </div>
                <div class="form-group row">
                    <div class="col-xs-3">
                        <label class = "caption-subject font-blue-secondary sbold">
                            Epílogo
                        </label>
                    </div>
                    <div class="col-xs-9">
                        <?php echo Form::textarea('epilogo', null, ['class' => 'form-control', 'style' => 'resize:none;', 'required' => 'required']); ?>

                    </div>
                </div>
                <div class="form-group row">
                    <div class="col-md-3 col-xs-12">
                        <label class = "caption-subject font-blue-secondary sbold">
                            Imagen
                        </label>
                    </div>
                    <div class="col-md-9 col-xs-12">
                        <div class="form-group col-xs-12">
                            <input name="img" type="file" class="filestyle" accept="image/jpeg" data-buttonText="Seleccionar un Archivo"
                                   data-placeholder="No se ha seleccionado ningun archivo"  data_buttonName="btn-primary" style = "width:400px;"/>
                            <label class="" style="margin:0; font-size:11px;">
                                Sólo se permite archivos en formato jpeg.
                            </label>
                        </div>
                    </div>
                </div>
                <div class="form-group row">
                    <div class="col-xs-3">
                        <label class = "caption-subject font-blue-secondary sbold">
                            Editorial
                        </label>
                    </div>
                    <div class="col-xs-9">
                        <?php echo Form::text('editorial', null, ['class' => 'form-control', 'required' => 'required']); ?>

                    </div>
                </div>
                <div class="form-group row">
                    <div class="col-xs-3">
                        <label class = "caption-subject font-blue-secondary sbold">
                            Tipo de Bibliografía
                        </label>
                    </div>
                    <div class="col-xs-9">
                        <?php echo Form::select('id_tipo_bibliografia', $tipos, $bibliografia->id_tipo_bibliografia,['class' => 'form-control select2', 'required' => 'required']); ?>

                    </div>
                </div>
                <div class="form-group row">
                    <div class="col-xs-3">
                        <label class = "caption-subject font-blue-secondary sbold">
                            Autor
                        </label>
                    </div>
                    <div id="the-basics" class="col-xs-9">
                        <?php echo Form::select('id_autor', array($bibliografia->id_autor => $autor->nombres),$bibliografia->id_autor,['class' => 'form-control', 'id'=>'Autores','text'=>'asdasdas', 'required' => 'required']); ?>

                    </div>
                </div>

                <?php if( ($bibliografia->url != "" || $bibliografia->url != null) && ($bibliografia->path != "" || $bibliografia->path != null)): ?>
                    <div id="subirarchivo">
                        <div class="col-xs-12 row" style="padding-top: 25px;padding-bottom: 25px">
                            <h4 class="page-head">
                                Subida del Documento
                            </h4>
                        </div>
                        <div class="form-group row">
                            <div class="col-xs-3">
                                <label class = "caption-subject font-blue-secondary sbold">
                                    Documento
                                </label>
                            </div>
                            <div class="col-xs-9">
                                <div class="form-group col-xs-12">
                                    <input name="documento" type="file" class="filestyle" accept="application/pdf" data-buttonText = "Seleccionar Archivo" data-placeholder="No se ha seleccionado ningun Archivo" data_buttonName = "btn-primary", @style  = "width:400px;"/>
                                    <label class="" style="margin:0; font-size:11px;">
                                        Sólo se permite archivos en formato PDF.
                                    </label>
                                </div>
                            </div>
                        </div>
                    </div>
                <?php endif; ?>

                <?php if( $bibliografia->url != null && $bibliografia->path == null): ?>
                    <div id="addenlace" >
                        <div class="form-group row">
                            <div class="col-md-3 col-xs-12">
                                <label class = "caption-subject font-blue-secondary sbold">
                                    Enlace al libro
                                </label>
                            </div>
                            <div class="col-md-9 col-xs-12">
                                <?php echo Form::text('url', null, ['class' => 'form-control','id' => 'enlacelibro', 'required' => 'required']); ?>

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

                <div class="actions">
                    <button type="submit" class="btn btn-primary mt-ladda-btn ladda-button">
                        <i class="fa fa-save"></i>
                        <span class="ladda-label" >Guardar</span>
                        <span class="ladda-spinner"></span>
                    </button>
                </div>
            </div>

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

<?php $__env->stopSection(); ?>
<?php $__env->startSection('scripts'); ?>
    <script>
        Ladda.bind('.mt-ladda-btn');
        var currentYear =  new Date().getFullYear().toString();
        $("#form-validation").validate();

        $(function () {
            $('.fecha_publicacion').datepicker({
                format: " yyyy",
                viewMode: "years",
                minViewMode: "years",
                maxViewMode: "years",
                endDate: currentYear,
                inline: true,
                autoclose:true
            });
        });

        $("#Autores").select2({
            ajax: {
                url: "<?php echo e(url('bibliografia/getautores')); ?>",
                dataType: 'json',
                delay: 250,
                data: function (params) {
                    return {
                        autores: params.term
                    };
                },
                processResults: function (data) {
                    return {
                        results:  $.map(data.data, function (item) {
                            return {
                                text: item.nombres,
                                id: item.id
                            }
                        })
                    };
                },
                cache: true
            },
            escapeMarkup: function (markup) { return markup; },
            minimumInputLength: 1
        });
    </script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('template.layout', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>