Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
4.7 kB
2
Indexable
Never
@extends('layout.master')

@push('plugin-styles')
    <link href="{{ asset('nobleui/assets/plugins/select2/select2.min.css') }}" rel="stylesheet" />
@endpush

@section('content')
    <nav class="page-breadcrumb">
        <ol class="breadcrumb">
            <li class="breadcrumb-item"><a href="#">Actividades</a></li>
            <li class="breadcrumb-item active" aria-current="page">Nueva</li>
        </ol>
    </nav>

    <div class="row">
        <div class="col-lg-12 grid-margin stretch-card">
            <div class="card">
                <div class="card-body">
                    @if ($errors->any())
                        <div class="alert alert-danger alert-dismissible fade show" role="alert">
                            @foreach ($errors->all() as $error)
                                <li>{{ $error }}</li>
                            @endforeach
                            <button type="button" class="btn-close" data-bs-dismiss="alert"
                                aria-label="btn-close"></button>
                        </div>
                    @endif
                    <h4 class="card-title">Registrarse a una actividad</h4>
                    <form class="cmxform" id="frmMisActividades" method="post" action="">
                        @csrf

                        <div class="row">
                            <div class="col-sm-6">
                                <div class="mb-3">
                                    <label class="form-label">Elegir tipo de actividad</label>
                                    <select class="form-select" id="TipoDeActividad" name="TipoDeActividad" required>
                                        <option selected="" disabled="">Click para seleccionar</option>
                                        @if ((isset($ListaCategorias)) && (count($ListaCategorias) > 0))
                                            @foreach ($ListaCategorias as $Categoria)
                                                <option value="{{ $Categoria->id }}">{{ $Categoria->nombre }}</option>
                                            @endforeach
                                        @endif
                                    </select>
                                </div>
                            </div>
                            <div class="col-sm-6">
                                <div class="mb-3">
                                    <label class="form-label">Disponibles</label>
                                    <select class="form-select" id="Actividad" name="Actividad" required>
                                        <option selected="" disabled="">Click para seleccionar</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <input class="btn btn-primary" type="submit" value="Guardar">
                    </form>
                </div>
            </div>
        </div>
    </div>
@endsection

@push('plugin-scripts')
    <script src="{{ asset('nobleui/assets/plugins/jquery-validation/jquery.validate.min.js') }}"></script>
    <script src="{{ asset('nobleui/assets/plugins/bootstrap-maxlength/bootstrap-maxlength.min.js') }}"></script>
    <script src="{{ asset('nobleui/assets/plugins/select2/select2.min.js') }}"></script>
@endpush

@push('custom-scripts')
    <script>
        $(document).ready(function () {
            var mensaje = "{{ Session::get('mensaje') }}";
            if(mensaje){
                mostrarMensaje(mensaje);
            }
        });
    </script>

    <script>
        $("#TipoDeActividad").change(function () {
            let idTipoDeActividad = $(this).val();
            let urlFinal = "{{ route('mis_actividades.lista_api_actividades', [':idTipoDeCategorias']) }}".replace(':idTipoDeCategorias', idTipoDeActividad);
            $.ajax({
                url: urlFinal,
                type : "GET",
                dataType : "json",
                data:{
                    _token: $('input[name="_token"]').val()
                }
            }).done(function(res){
                $('#Actividad').html("<option selected='' disabled=''>Click para seleccionar</option>");
                if(res.length)
                {
                    for (let index = 0; index < res.length; index++)
                    {
                        let InsertarOpcion = "<option value='"+res[index].id+"'>"+res[index].nombre+"</option>";
                        $('#Actividad').append(InsertarOpcion);
                    }
                }
            })
        });
    </script>

@endpush