@extends('layouts.landing')

@section('head')
    @include('layouts._partials.tablaStyle')
@endsection
@section('title',"Inicio")

@section('content')

<div class="container-fluid">
    <div class="card shadow mb-4">
        <div class="card-header py-3">
            <div class="d-sm-flex align-items-center justify-content-between">
                        <h6 class="m-0 font-weight-bold text-primary">grupos</h6>
                        @can('grupo.create')
                        <a href="{{route('grupo.create')}}" class="d-sm-inline-block btn btn-sm btn-primary shadow-sm"><i class="fas fa-download fa-sm text-white-50"></i> Crear Grupo</a>
                        @endcan
            </div>
        </div>

        <div class="card-body">
            <div class="container-fluid">

                    <table id="tcont" class="table table-striped table-bordered nowrap table-hover" style="width:100%;">
                        <thead>
                            <tr>
                                <th>Id</th>
                                <th>Nombre</th>
                                <th>Clave</th>
                                <th>Opciones</th>
                            </tr>
                        </thead>
                        <tbody>
                                @forelse ($grupos as $grupo)
                                    <tr style="width:100%">
                                        <td>{{$grupo->id}}</td>
                                        <td><a href="{{route('grupo.show',$grupo->id)}}">{{ $grupo->plan->carreraRel->name }}
                                        ({{ $grupo->plan->name }}-{{ $grupo->plan->rvoe }})</a></td>

                                        <td>{{$grupo->clave}}</td>

                                        <td class="row mx-auto">
                                            @can('grupo.edit')
                                            <div class="col-sm-6 col-md-6"><a class="btn btn-primary" href="{{route('grupo.edit',$grupo->id)}}">Edit</a></div>
                                            @endcan

                                            @can('grupo.destroy')
                                            <div class="col-sm-6 col-md-6">
                                                <form class="delete-form" action="{{route('grupo.destroy',$grupo->id)}}" method="POST">
                                                @csrf
                                                @method('DELETE')
                                                <input type="submit" value="DELETE" class="btn btn-danger">
                                                </form>
                                            </div>
                                            @endcan

                                            @hasrole('Docente')
                                            <div class="col-sm-6 col-md-6">
                                                <a class="btn btn-primary" href="{{ route('grupo.administrar', $grupo->id) }}">
                                                    <i class="fas fa-tasks fa-sm"></i> Administrar
                                                </a>
                                            </div>
                                            @endhasrole

                                            @hasrole('Coordinación académica')
                                            <div class="col-sm-6 col-md-6">
                                                <a class="btn btn-info" href="{{ route('grupo.ver.materias', $grupo->id) }}">
                                                    <i class="fas fa-eye fa-sm"></i> Ver Tareas
                                                </a>
                                            </div>
                                            @endhasrole

                                        </td>
                                    </tr>
                                @empty
                                    <p>Sin grupos.</p>
                                @endforelse

                        </tbody>
                    </table>



            </div>
        </div>
    </div>
</div>

@endsection


@section('scripts')
    @include('layouts._partials.tablaScript')
    @include('layouts._partials.delete')
@endsection
