@extends('layouts.dashboard')

@section('content')
    <section class="container-fluid all-container">
        <div class="header-titulo">
            Usuario
        </div>
        <div class="card mb-3">
            <div class="card-header titulo-eliminar">
                <div class="button-title">
                <strong>{{ucfirst($users->role)}}</strong>
                </div>
                <div class="eliminar-container">
                    <div class="btn-group mr-2">
                        @if($users->role != 'admin')
                            <button class="btn btn-sm btn-outline-secondary" onclick="window.location='{{ route("asignarApp",[$users->id]) }}'" data-toggle="tooltip" data-placement="bottom" title="Asignar aplicacion"><i class="fas fa-plus"></i></button>
                        @endif
                        <button class="btn btn-sm btn-outline-secondary" onclick="editar()"  data-toggle="tooltip" data-placement="bottom" title="Editar"><i class="fas fa-edit"></i></button>
                        <button class="btn btn-sm btn-outline-secondary" onclick="eliminarUser('{{ route("eliminar-user",[$users->id]) }}','{{ route('users') }}')"  data-toggle="tooltip" data-placement="bottom" title="Eliminar"><i class="far fa-trash-alt" ></i></button>
                    </div>
                </div>
            </div>
            <div class="card-body">
                <form action="{{ route('updateUser',[$users->id]) }}"  enctype="multipart/form-data" class="form-inlin mt-2" method="post" id="form-datos">
                    {{ csrf_field() }}
                    @if ($errors->any())
                        <div class="alert alert-danger text-center">
                            Error!.<br> Asegurese de llenar los datos correctamente
                        </div>
                    @endif
                    <div class="containe">
                        <div class="row">
                            <div class = "col-md-3 text-center pic-container">
                                <label for="file-input">
                                    <img id="image-profile-img" class="card-img-top" src="{{ asset('storage/users/'.$users->id)}}" alt="Card image cap">
                                    <input id="img-file" name="img" class="image-profile-input" value="" type="file" onchange="cargarIMG(this.files[0])" accept="image/*">
                                </label>
                                <button type = "button" class = "btn btn-info active btn-s button-pic" id ="open-image" onclick="($('#img-file').click())"> 
                                    <i class="fas fa-camera"></i>
                                </button>
                            </div>
                            <div class="col-md-9">
                                <div class="container">
                                    <div class="row">
                                        <div class="form-group col-md-6">
                                            <label>Nombre:</label>
                                            <input type="text" id="name" name="name" class="form-control" value="{{$users->name}}" placeholder="Nombre" required disabled>
                                        </div>
                                        <div class="form-group col-md-6">
                                            <label>Apellido:</label>
                                            <input type="text" class="form-control" id="surname" name="surname" value="{{$users->surname}}" placeholder="Apellido" required disabled>
                                        </div>
                                        <div class="form-group col-md-6">
                                            <label>Correo Electronico:</label>
                                            <input type="email" class="form-control" id="email" name="email" value="{{$users->email}}" placeholder="Correo Electronico" required disabled>
                                        </div>
                                        <div class="form-group col-md-6">
                                            <label>Telefono:</label>
                                            <input id="tel" type="nomber" class="form-control" name="tel" value="{{$users->tel}}"  required placeholder="Telefono" required disabled>
                                        </div>
                                        <div class="form-group col-md-6">
                                            <label>Direccion:</label>
                                            <input id="address" type="text" class="form-control" name="address" value="{{$users->address}}" required placeholder="Direccion" disabled>
                                        </div>
                                        <div class="form-group col-md-6">
                                            <label for="" class="form-label-title">Cedula:</label>
                                            <input id="cedula" type="text" class="form-control" name="idCard" value="{{$users->idCard}}" required placeholder="Cedula" disabled>
                                        </div>
                                        <div class="form-group col-md-6">
                                            <label>Tipo de usuario :</label>
                                            <span class="form-control span-edit-show">{{ucfirst($users->role)}}</span>
                                            <select name="role" id="role" id="role" class="form-control span-edit-hidden" required disabled>
                                                <option value="admin">Admin</option>
                                                <option value="cliente">Cliente</option>
                                                <option value="desarrollador">Desarrollador</option>
                                            </select>
                                        </div>
                                        <div class="form-group col-md-6">
                                            <label>Estado :</label>
                                            <span class="form-control span-edit-show">{{$users->estado}}</span>
                                            <select name="estado" id="estado" id="estado" class="form-control span-edit-hidden" required disabled>
                                                <option value="ACTIVO">ACTIVO</option>
                                                <option value="INACTIVO">INACTIVO</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="col-md-12 text-center" id="button-editar-container">
                                        <a href="{{ url()->previous() }}" class="btn btn-dark">Cancelar</a>
                                        <button type="submit" class="btn btn-light light2">Guardar</button>
                                    </div> 
                                </div>                                
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
        
        @if( $users->role != 'admin')
        <div class="card mb-3">
            <div class="card-header">
            <i class="fas fa-ruler"></i> Aplicaciones del usuario
            </div>
            <div class="card-body">
                <div class="container">
                    <div class="row">
                        @if ( $aplicacion_name == '[]')
                          <small>Este usuario no tiene aplicaciones</small>
                        @endif
                        @foreach($aplicacion_name as $aplicaciones)
                            <div class="col-md-4 list-group-item list-group-item-action flex-column pointer">
                                <i onclick="destroyAppUser('{{ route("destroyAppUser",[$aplicaciones->id]) }}')"class="fas fa-backspace float-right deleteIcon"></i>
                                <a href="{{ route('aplicacion',[$aplicaciones->app_id]) }}" class="d-flex w-100 justify-content-between appLink">
                                    <h5 class="mb-1">{{$aplicaciones->app_name}}</h5>
                                </a>
                            </div>
                        @endforeach
                    </div>
                </div>
            </div>
        </div>
        @endif
        @if( $users->role == 'desarrollador')
        <div class="card mb-3">
            <div class="card-header">
            <i class="fas fa-ruler"></i> Requerimientos del desarrollador
            </div>
            <div class="card-body">
                <div class="container">
                    <div class="row">
                        @if ( $requerimientos_desarrollador == '[]')
                          <small>Este desarrollador no tiene requerimientos</small>
                        @endif
                        @foreach($requerimientos_desarrollador as $requerimiento)
                            <a href="{{ route('requerimiento',[$requerimiento->requerimiento_id]) }}" class="col-md-4 list-group-item list-group-item-action flex-column align-items-start">
                                <div class="d-flex w-100 justify-content-between">
                                <h5 class="mb-1">{{$requerimiento->requerimiento_titulo}}</h5>
                                </div>
                                <p class="mb-1">{{$requerimiento->requerimiento_descripcion}}.</p>
                                <small class="text-muted">{{$requerimiento->updated_at}}</small>
                            </a>
                        @endforeach
                    </div>
                </div>
            </div>
        </div>
        @endif
    <section>
    <style>        
        #mainNav.navbar-dark .navbar-collapse .navbar-sidenav>.nav-item>.userLink {color:#1c8dff;}
    </style>
    <script  src="{{ asset('js/admin.js') }}"> </script>  
	<script src="{{ asset('js/user.js') }}"></script>
	<script src="{{ asset('js/sweetalert.min.js') }}"></script>
    <link  media="all" rel="stylesheet" type="text/css" href="{{ asset('css/admin.css') }}">
    <link  media="all" rel="stylesheet" type="text/css" href="{{ asset('css/general.css') }}">
@endsection