@extends('layouts.admin')
@section ('title')
SisVentas | Categorias
@endsection
@section('contenido')
<!-- start page title -->
<div class="row">
    <div class="col-12">
        <div class="page-title-box">
            <div class="page-title-right">
                <ol class="breadcrumb m-0">
                    <li class="breadcrumb-item"><a href="javascript: void(0);">Inicio</a></li>
                    <li class="breadcrumb-item"><a href="javascript: void(0);">Almacen</a></li>
                    <li class="breadcrumb-item active">Categorias</li>
                </ol>
            </div>
            <h4 class="page-title">Administración de Categorias</h4>
        </div>
    </div>
</div>     
<!-- end page title --> 

<div class="row">
    <div class="col-12">
        <div class="card">
            <div class="card-body">
                <div class="row mb-2">
                    <div class="col-sm-4">
                        @can('categoria-create')
                        <a href="{{ route('categoria.create') }}" class="btn btn-success mb-2"><i class="mdi mdi-plus-circle me-2"></i> Nuevo Categoria</a>
                        @endcan
                    </div>
                    <div class="col-sm-8">
                        <div class="text-sm-end">
                            <a href="{{url('reportecategorias')}}" target="__blank" class="btn btn-danger mb-2"><i class="mdi mdi-printer"></i> Reporte</a>
                        </div>
                    </div><!-- end col-->
                    @include('almacen.categoria.search')
                </div>                
                <div class="table-responsive">
                    <table class="table table-centered w-100 dt-responsive nowrap table-bordered table-condensed table-hover"> 
                        <thead class="table-light">
                            <tr>
                                <th>Id</th>
                                <th>Nombres</th>
                                <th>Descripción</th>
                                <th style="width: 250px;">Acciones</th>
                            </tr>
                        </thead>
                        
                        <tbody>
                            @foreach ($categorias as $cat)
                            <tr>
                                <td>{{ $cat->idcategoria }}</td>
                                <td>{{ $cat->nombre }}</td>
                                <td>{{ $cat->descripcion }}</td>
                                <td align="center">
                                    @can('categoria-edit')
                                    <a href="{{route('categoria.edit',$cat->idcategoria)}}"><button class="btn btn-info"><i class="mdi mdi-square-edit-outline"></i> Editar</button></a>
                                    @endcan
                                    @can('categoria-delete')
                                    <button type="button" class="btn btn-danger" data-bs-toggle="modal" data-bs-target="#modal-delete-{{$cat->idcategoria}}"><i class="mdi mdi-delete"></i> Eliminar</button>
                                    @endcan
                                </td>
                            </tr>
                            @include('almacen.categoria.modal')
                            @endforeach
                        </tbody>
                        
                    </table>
                    {{$categorias->render()}}
                </div>
            </div> <!-- end card-body-->
        </div> <!-- end card-->
    </div> <!-- end col -->
</div>
@push ('scripts')
<script>
    $('#liAlmacen').addClass("sub active");
    $('#aAlmacen').addClass("active");
    $('#liCategorias').addClass("active");
</script>
@endpush
@endsection