<?php $__env->startSection('styles'); ?>
    <link href="<?php echo e(asset('css/pages/perfil.min.css')); ?>" rel="stylesheet" type="text/css" />
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
    <h1 class="page-title"> Perfil
        <small><?php echo e(Auth::user()->role); ?></small>
    </h1>
    <div class="profile">
        <?php echo $__env->make('alerts.index', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
        <div class="row profile-account">
            <div class="col-md-3">
                <ul class="ver-inline-menu tabbable margin-bottom-10">
                    <li>
                        <?php if(is_null($usuario->urlimagen)): ?>
                            <img src="<?php echo e(asset('img/demo/perfil.jpg')); ?>" class="img-responsive pic-bordered profile-img" alt="img-perfil"/>
                        <?php else: ?>
                            <img src="<?php echo e(asset($usuario->urlimagen)); ?>" class="img-responsive pic-bordered profile-img" alt="img-perfil"/>
                        <?php endif; ?>
                    </li>
                    <li class="active">
                        <a data-toggle="tab" href="#tab_1" class="text-ellipsis">
                            <i class="fa fa-cog"></i> Informaci&oacute;n personal </a>
                        <span class="after"> </span>
                    </li>
                    <li>
                        <a data-toggle="tab" href="#tab_2" class="text-ellipsis">
                            <i class="fa fa-lock"></i> Cambiar contrase&ntilde;a </a>
                    </li>
                    <?php if(!(auth()->user()->roleid == config('constants.ROLES.APODERADO'))): ?>
                        <li>
                            <a data-toggle="tab" href="#tab_3" class="text-ellipsis">
                                <i class="fa fa-eye"></i> Experiencia laboral </a>
                        </li>
                    <?php endif; ?>
                </ul>
            </div>
            <div class="col-md-9">
                <div class="tab-content">
                    <div id="tab_1" class="tab-pane active">
                        <div class="profile-info">
                            <h1 class="font-green sbold uppercase"><?php echo e($usuario->fullName); ?></h1>
                            <ul class="list-inline">
                                <li>
                                    <i class="fa fa-user"></i> <?php echo e($usuario->dni); ?> </li>
                                <li>
                                    <i class="fa fa-genderless"></i> <?php echo e($usuario->genero); ?> </li>
                                <li>
                                    <i class="fa fa-asterisk"></i> <?php echo e($usuario->estado_civil); ?> </li>
                                <?php if(!is_null($alumno) && $alumno->titulado > 0): ?>
                                    <li>
                                        <i class="fa fa-graduation-cap"></i> Titulado </li>
                                <?php endif; ?>
                            </ul>
                        </div>

                        <?php echo e(Form::open(array('id' => 'form-datos','route' => 'perfil.datos'))); ?>

                        <div class="row">
                            <?php echo Form::hidden('id', $usuario->id); ?>

                            <div class="col-md-6 form-group">
                                <label class="control-label">Tel&eacute;fono</label>
                                <?php echo Form::text('telefono', null, array('placeholder' => $usuario->telefono,'class' => 'form-control', 'maxlength' => '9')); ?>

                            </div>
                            <div class="col-md-6 form-group">
                                <label class="control-label">Correo</label>
                                <?php echo Form::email('correo', null, array('placeholder' => $usuario->email,'class' => 'form-control')); ?>

                            </div>
                            <div class="col-md-12 form-group">
                                <label class="control-label">Direcci&oacute;n</label>
                                <?php echo Form::text('direccion', null, array('placeholder' => $usuario->direccion,'class' => 'form-control', 'maxlength' => '50')); ?>

                            </div>
                            <div class="col-md-12 form-group">
                                <label class="control-label">Descripci&oacute;n</label>
                                <?php echo Form::textarea('descripcion', null, array('placeholder' => $usuario->descripcion,'class' => 'form-control', 'maxlength' => '500', 'style' => 'resize: none;')); ?>

                            </div>
                        </div>
                        <div class="margin-top-10">
                            
                            <button type="submit" class="btn btn-primary"> Guardar cambios </button>
                        </div>
                        <?php echo Form::close(); ?>

                    </div>
                    <div id="tab_2" class="tab-pane">
                        <?php echo e(Form::open(array('id' => 'form-password','route' => 'perfil.password'))); ?>

                        <div class="row">
                            <?php echo Form::hidden('id', $usuario->id); ?>

                            <div class="col-md-12 form-group">
                                <label class="control-label">Contrase&ntilde;a actual</label>
                                <?php echo Form::password('password', array('class' => 'form-control', 'required' => 'required')); ?>

                            </div>
                            <div class="col-md-12 form-group">
                                <label class="control-label">Nueva Contrase&ntilde;a</label>
                                <?php echo Form::password('newpassword', array('id' => 'newpassword', 'class' => 'form-control', 'required' => 'required')); ?>

                            </div>
                            <div class="col-md-12 form-group">
                                <label class="control-label">Re-ingrese su nueva contrase&ntilde;a</label>
                                <?php echo Form::password('repassword', array('id' => 'repassword', 'class' => 'form-control', 'required' => 'required')); ?>

                            </div>
                        </div>
                        <div class="margin-top-10">
                            
                            <button type="submit" class="btn btn-primary"> Guardar cambios </button>
                        </div>
                        <?php echo Form::close(); ?>

                    </div>
                    <?php if(!(auth()->user()->roleid == config('constants.ROLES.APODERADO'))): ?>
                        <div id="tab_3" class="tab-pane">
                            <div class="portlet">
                                <div class="portlet-title">
                                    <div class="caption">
                                        <i class="fa fa-gift"></i> Experiencia laboral
                                    </div>
                                    <div class="actions">
                                        <a href="<?php echo e(url('perfil/experiencia/registrar')); ?>" class="btn btn-primary">
                                            <i class="fa fa-plus"></i><span class="hidden-xs"> Agregar experiencia laboral </span>
                                        </a>
                                    </div>
                                    <div class="tools" style="margin-right: 5px;">
                                        <a id="reload-exp" href="javascript:;" data-load="true" data-url="<?php echo e(url('perfil/experiencias')); ?>" class="reload"> </a>
                                    </div>

                                </div>
                                <div class="portlet-body portlet-empty"> </div>
                            </div>
                        </div>
                    <?php endif; ?>
                </div>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('scripts'); ?>
    <?php if(!(auth()->user()->roleid == config('constants.ROLES.APODERADO'))): ?>
        <script src="<?php echo e(asset('plugins/jquery-slimscroll/jquery.slimscroll.min.js')); ?>" type="text/javascript"></script>
    <?php endif; ?>
    <script>
        $('#form-datos').validate({
            rules: {
                telefono: {
                    pattern: '^[0-9]{7,9}$'
                },
            }
        });
        $('#form-password').validate({
            rules: {
                newpassword : {
                    minlength : 5,
                },
                repassword : {
                    equalTo : "#newpassword"
                },
            }
        });
        function reload() {
            var el = $('#reload-exp').closest(".portlet").children(".portlet-body");
            var url = $('#reload-exp').attr("data-url");
            var error = $('#reload-exp').attr("data-error-display");
            if (url) {
                App.blockUI({
                    target: el,
                    animate: true,
                    overlayColor: 'none'
                });
                $.ajax({
                    type: "GET",
                    cache: false,
                    url: url,
                    dataType: "html",
                    success: function(res) {
                        App.unblockUI(el);
                        el.html(res);
                        App.initAjax() // reinitialize elements & plugins for newly loaded content
                    },
                    error: function(xhr, ajaxOptions, thrownError) {
                        App.unblockUI(el);
                        var msg = 'Error on reloading the content. Please check your connection and try again.';
                        if (error == "toastr" && toastr) {
                            toastr.error(msg);
                        } else if (error == "notific8" && $.notific8) {
                            $.notific8('zindex', 11500);
                            $.notific8(msg, {
                                theme: 'ruby',
                                life: 3000
                            });
                        } else {
                            alert(msg);
                        }
                    }
                });
            }
        }
        function eliminarExp(id) {
            swal({
                    title: "¿Está seguro?",
                    text: "Se eliminará la experiencia laboral seleccionada",
                    type: "warning",
                    confirmButtonText: "Si",
                    cancelButtonText: " No",
                    showCancelButton: true,
                    closeOnConfirm: false,
                    showLoaderOnConfirm: true,
                },
                function () {
                    
                    $.ajax({
                        url: '<?php echo e(url('perfil/experiencia/eliminar')); ?>',
                        type: "POST",
                        data: {
                            id: id
                        },
                        success: function (result) {
                            if (result) {
                                swal({
                                    title: 'Experiencia laboral eliminada',
                                    text: "El registro se eliminó exitosamente!",
                                    type: 'success',
                                    showCancelButton: false,
                                    showConfirmButton: true,
                                    showLoaderOnConfirm: true,
                                })
                                reload();
                            }
                            else {
                                swal("El anuncio ya ha sido enviado!", "No se puede eliminar el anuncio!", "error");
                            }
                        }
                    });
                });
        };

    </script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('template.layout', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>