@extends('layouts.app')

@section('title',"My perfil ")

@section('content')
@section('scripts_url')
<script src="{!! asset('assets/file/js/piexif.min.js') !!}" type="text/javascript"></script>
<link href="{!! asset('assets/file/css/fileinput.min.css') !!}" rel="stylesheet" type="text/css">
<script src="{!! asset('assets/file/js/fileinput.min.js') !!}"></script>
@endsection
<div class="response-files" style="display: none;"></div>

<div class="card">
	<div class="card-header header-elements-inline">
		<h5 class="card-title"><i class="icon-vcard"></i> Mis datos</h5>
		<div class="header-elements">
			<div class="list-icons">
        		<a class="list-icons-item" data-action="collapse"></a>
        		<a class="list-icons-item" data-action="reload"></a>
        		<a class="list-icons-item" data-action="remove"></a>
        	</div>
    	</div>
	</div>
	<div class="card-body mt-2">
		<form action="{{ url('profile') }}" method="POST" id="form-file" onsubmit="submitFile(this); return false">		
			<input type="hidden" name="action" value="update">
			<input type="hidden" name="carpeta_file" value="Profile">
			<div class="row">
				<div class="col-lg-3 col-xl-3">
					<label for=""><b>Email:</b></label>
					<input type="text" name="email" value="{{ $user->email }}" class="form-control">
				</div>
				<div class="col-lg-3 col-xl-3">
					<label for=""><b>Nombre:</b></label>
					<input type="text" name="name" value="{{ $user->name }}" class="form-control">
				</div>
				<div class="col-lg-3 col-xl-3">
					<label for=""><b>Nombre Empresa:</b></label>
					<input type="text" name="nempresa" value="{{ $user->nempresa }}" class="form-control">
				</div>
				<div class="col-lg-3 col-xl-3">
					<label for=""><b>Direccion Empresa:</b></label>
					<input type="text" name="direccion" value="{{ $user->direccion }}" class="form-control">
				</div>
			</div>
			<div class="row mt-2">
				<div class="col-lg-6 col-xl-6">
					<label for=""><b>Ruc:</b></label>
					<input type="text" name="ruc"  value="{{ $user->ruc }}" class="form-control">
				</div>
				<div class="col-lg-6 col-xl-6">
					<label for=""><b>Password:</b></label>
					<input type="password" name="password"  class="form-control">
				</div>
			</div>
			<div class="row justify-content-center">
				<div class="col-lg-6 col-xl-6">
					<label for=""><b>Imagen de perfil:</b></label>
					<input  name="file" type="file" id="file_edit" class="file text-center" multiple 
	                  data-show-upload="false" data-show-caption="true" data-msg-placeholder="Select {files} for upload..." > 
				</div>
			</div>
			<div class="row mt-2">
				<div class="col-12 text-center ">
					<button class="btn btn-primary"><i class="icon-rotate-cw2 "></i> ACtualizar</button>
				</div>
			</div>
		</form>
	</div>
</div>

	@section('scripts')
	<script src="{!! asset('assets/views_functions/user.js') !!}"></script>
		@if (session('update_success'))
	    <script>
	    	$.noty_success('{{ session("update_success") }}');
	    </script>
		@endif
		<script>
			let url = "{{ (!empty(Auth::user()->src_file)) ? asset('storage/'.Auth::user()->src_file) : '' }}";
			$("#file_edit").fileinput({
			    initialPreview: url,
			    initialPreviewAsData: true,
			    initialPreviewConfig: [
			        {caption: "Image", downloadUrl: url, key: 1},
			    ],
			    overwriteInitial: true,
			    showUpload: false,
			    showDelete: false,
			    initialCaption: ''
			})
		</script>
	@endsection
@endsection