<?php $__env->startSection('content'); ?>
    <section class="container all-container">
        <div class="header-titulo">
            Aplicacion
        </div>
        <nav>
            <div class="nav nav-tabs" id="nav-tab" role="tablist">
                <a class="nav-item nav-link active" id="nav-home-tab" data-toggle="tab" href="#nav-home" role="tab" aria-controls="nav-home" aria-selected="true">Aplicacion</a>
                <a class="nav-item nav-link" id="nav-profile-tab" data-toggle="tab" href="#nav-profile" role="tab" aria-controls="nav-profile" aria-selected="false">Usuarios de la aplicacion</a>
            </div>
        </nav>
        <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
            <div class="modal-dialog modal-agregar-user mx-auto" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <div class="title-buscador-container">
                            <div class="tabla-buscador">
                                <div class="barra-container">
                                    <select class="form-control pagination-option" url="<?php echo e(URL::to('NotAppUser')); ?>" id="filtroUsuarios" onchange="filtrarUsuarios(this.value,<?php echo e($aplicacion->id); ?>)">
                                        <option value="cliente">Clientes</option>
                                        <option value="desarrollador">Desarrolladores</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <button type="button" class="btn btn-light" id="save-user">
                            <i class="fas fa-save"></i>
                        </button>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                    <div class="modal-body">
                        <form action="<?php echo e(route('asignarUsuario',[$aplicacion->id])); ?>" method="post"  id="form-datos">
                            <?php echo e(csrf_field()); ?>

                            <div class="container">
                                <div class="row" id="users-container">
                                    <?php if( $usersByRole == '[]'): ?>
                                    <small>No hay mas usuarios disponibles para esta aplicacion</small>
                                    <?php endif; ?>
                                    <?php $__currentLoopData = $usersByRole; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $userByRole): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <div class="col-md-3 list-group-item list-group-item-action flex-column pointer user-select">
                                            <div class="w-100">
                                                <h5 class="mb-1 size-1m"><?php echo e($userByRole->name); ?> .<?php echo e(substr(ucfirst($userByRole->surname), 0, 1)); ?></h5>
                                                <small class="text-muted user-card"><?php echo e($userByRole->email); ?></small>
                                                <input class="envio" type="hidden" name="user" value="<?php echo e($userByRole->id); ?>">
                                            </div>
                                        </div>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </div>
                                    <input type="hidden" id="asignarUsuario" value="<?php echo e(route('asignarUsuario')); ?>">
                                    <input type="hidden" id="token" value="<?php echo e(csrf_token()); ?>" >
                                    <input id="app_name" class="envio" type="hidden" name="app" value="<?php echo e($aplicacion->id); ?>">
                            </div>
                        </form>
                    </div>
                    <div class="modal-footer">
                        <!-- <nav aria-label="Page navigation example">
                            <ul class="pagination paginador">
                                <li class="page-item"><a class="page-link" href="#">Previous</a></li>
                                <li class="page-item"><a class="page-link" href="#">1</a></li>
                                <li class="page-item"><a class="page-link" href="#">2</a></li>
                                <li class="page-item"><a class="page-link" href="#">3</a></li>
                                <li class="page-item"><a class="page-link" href="#">Next</a></li>
                            </ul>
                        </nav> -->
                    </div>
                </div>
            </div>
        </div>
        <div class="tab-content" id="nav-tabContent">
            <div class="tab-pane fade show active" id="nav-home" role="tabpanel" aria-labelledby="nav-home-tab">
                <div class="card mb-3">
                    <div class="card-header titulo-eliminar">
                        <div class="title">
                        </div>
                        <div class="eliminar-container">
                            <div class="btn-group mr-2">
                                <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="eliminarApp('<?php echo e(route("eliminar-aplicacion",[$aplicacion->id])); ?>','<?php echo e(route('aplicaciones')); ?>')" data-toggle="tooltip" data-placement="bottom" title="Eliminar"><i class="far fa-trash-alt" ></i></button>
                            </div>
                        </div>
                    </div>
                    <div class="card-body padding-10">
                        <form action="<?php echo e(route('actualizarAplicacion',[$aplicacion->id])); ?>" method="post"  id="form-datos">
                            <?php echo e(csrf_field()); ?>

                            <?php if($errors->get('estado')): ?>
                                <div class="alert alert-danger text-center">
                                    Error!.<br> Asegurese de llenar los datos correctamente
                                </div>
                            <?php endif; ?>
                            <div class="form-group row">
                                <label for="inputEmail3" class="col-sm-2 col-form-label">Nombre</label>
                                <div class="col-sm-10">
                                    <input type="text" id="nombre" value="<?php echo e($aplicacion->nombre); ?>" name="nombre"  class="form-control" placeholder="Nombre" disabled required>
                                </div>
                            </div>
                            <div class="form-group row">
                                <label for="inputPassword3" class="col-sm-2 col-form-label">Codigo</label>
                                <div class="col-sm-10">
                                <input type="text" id="codigo" value="<?php echo e($aplicacion->codigo); ?>" name="codigo"  class="form-control" placeholder="codigo" disabled required>
                                </div>
                            </div>
                            <div class="form-group row">
                                <div class="col-sm-2">Tipo</div>
                                <div class="col-sm-10 col-md-2">
                                    <span class="form-control span-edit-show"><?php echo e($aplicacion->tipo); ?></span>
                                    <select class="form-control span-edit-hidden" name="tipo" disabled required>
                                        <option value="proyecto">Proyecto</option>
                                        <option value="sistema">Sistema</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group row">
                                <div class="col-sm-2">Estado</div>
                                <div class="col-sm-10 col-md-2">
                                    <span class="form-control span-edit-show"><?php echo e($aplicacion->estado); ?></span>
                                    <select class="form-control span-edit-hidden" name="estado" disabled required>
                                        <option value="activo">Activo</option>
                                        <option value="inactivo">Inactivo</option>
                                    </select>
                                </div>
                            </div>
                            <fieldset class="form-group">
                                <div class="row">
                                    <legend class="col-form-label col-sm-2 pt-0">Descripcion</legend>
                                    <div class="col-sm-10">
                                    <textarea  style="resize: none;" rows="5" id="textarea" name="descripcion" class="form-control" disabled required><?php echo e($aplicacion->descripcion); ?></textarea>
                                    </div>
                                </div>
                            </fieldset>
                            <div class="form-group buttons-edit-container row">
                                <div class="col-sm-10">
                                    <button type="button" onclick="editar()" id="button-editar" class="btn btn-dark">Cancelar</button>
                                    <button type="submit" class="btn btn-light" id="button-guardar">Guardar</button>
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="card-footer small text-muted">
                        Updated <?php echo e($aplicacion->updated_at); ?>

                    </div>
                </div>
                
                <div class="card mb-3">
                    <div class="card-header">
                    <i class="fas fa-ruler"></i> Modulos de la aplicacion
                    </div>
                    <div class="card-body">
                        <div class="container">
                            <div class="row">
                                <?php if( $modulos == '[]'): ?>
                                <small>Esta aplicacion no tiene modulos</small>
                                <?php endif; ?>
                                <?php $__currentLoopData = $modulos; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $modulo): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <div class="col-md-4 list-group-item list-group-item-action flex-column pointer">
                                        <i onclick="destroyModule('<?php echo e(route('eliminarModulo',[$modulo->id])); ?>')" class="fas fa-backspace float-right deleteIcon"></i>
                                        <div onclick="window.location='<?php echo e(route("modulo",[$modulo->id])); ?>'" class="d-flex w-100 justify-content-between">
                                            <h5 class="mb-1"><?php echo e($modulo->nombre); ?></h5>
                                        </div>
                                    </div>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="tab-pane fade" id="nav-profile" role="tabpanel" aria-labelledby="nav-profile-tab">
            
                <div class="card mb-3">
                    <div class="card-header titulo-eliminar">
                        <div class="title">
                        </div>
                        <div class="eliminar-container">
                            <button class="btn btn-sm btn-outline-secondary" data-toggle="modal" data-target="#exampleModal" title="Agregar usuario"><i class="fas fa-user-plus"></i></button>
                            
                        </div>
                    </div>
                    <div class="card-body">
                        <legend class="col-form-label col-sm-4 pt-0"><h5> Clientes: </h5></legend>
                        <div class="container">
                            <div class="row">
                                <?php if( $clientes == '[]'): ?>
                                <small class="text-muted">Esta aplicacion no tiene clientes</small>
                                <?php endif; ?>
                                <?php $__currentLoopData = $clientes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $cliente): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <div class="col-md-4 list-group-item list-group-item-action flex-column pointer">
                                        <i onclick="EliminarUsuarioApp('<?php echo e(route('EliminarUsuarioApp',[$cliente->id])); ?>')" class="fas fa-backspace float-right deleteIcon"></i>
                                        <div onclick="window.location='<?php echo e(route("user",[$cliente->user_id])); ?>'" class="d-flex w-100 justify-content-between">
                                            <h5 class="mb-1 size-1m"><?php echo e($cliente->name); ?> .<?php echo e(substr(ucfirst($cliente->surname), 0, 1)); ?></h5>
                                            <small class="text-muted user-card"><?php echo e($cliente->email); ?></small>
                                        </div>
                                    </div>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </div>
                        </div><hr>
                        <legend class="col-form-label col-sm-4 pt-0 mt-4"><h5> Desarrolladores: </h5></legend>
                        <div class="container">
                            <div class="row">
                                <?php if( $desarrolladores == '[]'): ?>
                                <small class="text-muted">Esta aplicacion no tiene desarrolladores</small>
                                <?php endif; ?>
                                <?php $__currentLoopData = $desarrolladores; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $desarrollador): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <div class="col-md-4 list-group-item list-group-item-action flex-column pointer">
                                        <i onclick="EliminarUsuarioApp('<?php echo e(route('EliminarUsuarioApp',[$desarrollador->id])); ?>')" class="fas fa-backspace float-right deleteIcon"></i>
                                        <div onclick="window.location='<?php echo e(route("user",[$desarrollador->user_id])); ?>'" class="d-flex w-100 justify-content-between">
                                            <h5 class="mb-1 size-1m"><?php echo e($desarrollador->name); ?> .<?php echo e(substr(ucfirst($desarrollador->surname), 0, 1)); ?></h5>
                                            <small class="text-muted user-card"><?php echo e($desarrollador->email); ?></small>
                                        </div>
                                    </div>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
    <style>        
        #mainNav.navbar-dark .navbar-collapse .navbar-sidenav>.nav-item>.aplicacionesLink {color:#c1d61e;}
    </style>
	<script src="<?php echo e(asset('js/sweetalert.min.js')); ?>"></script>
	<link  media="all" rel="stylesheet" type="text/css" href="<?php echo e(asset('css/general.css')); ?>">
	<script src="<?php echo e(asset('js/aplicacion.js')); ?>"></script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.dashboard', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>