

<?php $__env->startSection('breadcrumb'); ?>
	<li class="breadcrumb-item"><a href="javascript:void(0);">Cuenta</a></li>
    <li class="breadcrumb-item active" aria-current="page"><span>Información personal</span></li>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('css'); ?>

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

<?php $__env->startSection('content'); ?>
<div class="row layout-spacing layout-top-spacing feather-icon">
    <div id="font-icon_feather" class="col-lg-12">
        <div class="statbox widget box box-shadow">
            <div class="widget-content widget-content-area bx-top-6">
                <div class="icon-section">
                    <div class="row">
                        <div class="col-xl-12">
                        	
                            <center><h4>Actualizar información</h4></center>
                            <hr>

                            <form action="<?php echo e(route('cuenta.update')); ?>" method="post" enctype="multipart/form-data">
                                <?php echo csrf_field(); ?>
                                
                                <div class="container">
                                  <div class="rounded-lg p-4 mb-4">
                                    <div class="media align-items-center">
                                        <div id="preview">
                                          <img src="<?php echo e(asset(Auth::user()->img)); ?>" width="90" alt="<?php echo e(Auth::user()->name); ?>">
                                        </div>
                                      <div class="media-body pl-3">
                                        <div class="custom-file">
                                          <input class="custom-file-input <?php $__errorArgs = ['foto'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" type="file" id="file-input" name="foto" accept="image/x-png,image/jpeg">
                                          <label class="custom-file-label" id="custom-file-label-user" for="file-input">Subir foto...</label>
                                            <?php $__errorArgs = ['foto'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                              <span class="invalid-feedback" role="alert">
                                                <strong><?php echo e($message); ?></strong>
                                              </span>
                                            <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                        </div>
                                        <div class="p mb-0 font-size-ms text-muted">Sube una foto en formato <strong>.PNG</strong> o <strong>.JPG</strong> <br> <strong>Max. 1Mb</strong></div>
                                      </div>
                                    </div>
                                  </div>
                                  <div class="row">
                                    <div class="col-sm-6">
                                      <div class="form-group">
                                        <label for="account-fn">Nombres</label>
                                        <input class="form-control" name="name" type="text" id="account-fn" value="<?php echo e(Auth::user()->name); ?>">
                                      </div>
                                    </div>
                                    <div class="col-sm-6">
                                      <div class="form-group">
                                        <label for="account-email">Correo electrónico</label>
                                        <input class="form-control" type="email" id="account-email" value="<?php echo e(Auth::user()->email); ?>" name="email">
                                      </div>
                                    </div>          
                                  </div>                                   
                                </div>
                                <div class="row">
                                    <div class="col">
                                        <br>
                                        <button type="submit" class="btn btn-primary float-right">Actualizar</button>
                                    </div>
                                </div>
                            </form>                                         
                        </div>
                    </div>
                </div>         
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('script'); ?>
    <script type="text/javascript">

        function fileValidation(){
            var fileInput = document.getElementById('file-input');
            var filePath = fileInput.value;
            var allowedExtensions = /(.jpg|.jpeg|.png)$/i;
            if(!allowedExtensions.exec(filePath)){
                return false;
            }else{
                return true;     
            }
        }

        document.getElementById("file-input").onchange = function (e) {
        // Creamos el objeto de la clase FileReader

        var validate = fileValidation();

        if (validate) {

          let archivo = document.getElementById("file-input");
          let peso = archivo.files[0].size;
          if(peso > 1000000) {
            Snackbar.show({
              text: 'Archivo muy pesado Tamaño máximo permitido es de 1Mb',
              pos: 'bottom-right',
              actionText:"Ok"
            }); 

            $("#file-input").val(''); 
            $('#custom-file-label-user').html('Subir foto...');

           }else{
              let reader = new FileReader();

              // Leemos el archivo subido y se lo pasamos a nuestro fileReader
              reader.readAsDataURL(e.target.files[0]);

              // Le decimos que cuando este listo ejecute el cÃ³digo interno
              reader.onload = function () {
                  let preview = document.getElementById('preview'),
                      image = document.createElement('img');

                  image.src = reader.result;

                  preview.innerHTML = '';
                  preview.append(image);
              };
           }
        }else{
            var file = $('#file-input').val();

            if (file!='') {
                Snackbar.show({
                  text: 'La extensión de la imagen no es válida, solo se permite extensiones .PNG o .JPG',
                  pos: 'bottom-right',
                  actionText:"Ok"
                }); 
              $('#file-input').val('');
              $('#custom-file-label-user').html('Subir foto...');
            }            
        }
    }

    $('#file-input').change(function () {

        var file = $('#file-input').val();

        if (file == '') {
            $('#preview').html('<img src="/img/profile.png">');
        }
    });
    </script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('admin.layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\guatehoteles\resources\views/admin/cuenta/cuenta.blade.php ENDPATH**/ ?>