MINI MINI MANI MO

Path : /var/www/html/sistemas/saplxi/resources/views/Administrador/comunicados/
File Upload :
Current File : /var/www/html/sistemas/saplxi/resources/views/Administrador/comunicados/index.blade.php

{{-- layout extend --}}
@extends('../Administrador/layouts.app')

{{-- page title --}}
@section('title', 'Diputados - ')

@section('vendor-style')
<link rel="stylesheet" type="text/css" href="{{asset('vendors/data-tables/css/jquery.dataTables.min.css')}}">
<link rel="stylesheet" type="text/css" href="{{asset('vendors/data-tables/extensions/responsive/css/responsive.dataTables.min.css')}}">
<link rel="stylesheet" type="text/css" href="{{asset('vendors/data-tables/css/select.dataTables.min.css')}}">
<link rel="stylesheet" type="text/css" href="{{asset('vendors/sweetalert/sweetalert.css')}}">
@endsection

{{-- page styles --}}
@section('page-style')
    <link rel="stylesheet" type="text/css" href="{{asset('css/pages/app-invoice.css')}}">
@endsection

@section('content')
<!-- invoice list -->
<section class="invoice-list-wrapper section">
    <!-- create invoice button-->
    <!-- Options and filter dropdown button-->
    <div class="seaction">
        <div class="row">
            <div class="col s12 m12 l12">
                <div id="button-trigger2" class="card card card-default scrollspy">
                    <div class="card-content">
                        <!-- create invoice button-->
                        <div class="invoice-create-btn">
                            <a href="{{route('mcg.comunicados.create')}}"
                                class="btn waves-effect waves-light invoice-create border-round z-depth-4">
                                <i class="material-icons">add</i>
                                <span class="hide-on-small-only">Registrar</span>
                            </a>
                        </div>
                        <br>
                        <div class="responsive-table">
                            <table class="table invoice-data-table white border-radius-4 pt-1" id="tableservicios">
                                <thead>
                                    <tr>
                                        <th><span>Número</span></th>
                                        <th>Título</th>
                                        <th>Foto principal</th>
                                        <th>Estado </th>
                                        <th>Funciones</th>
                                    </tr>
                                </thead>

                                <tbody>

                                    @foreach ($comunicados as $item)
                                    <tr>
                                        <td>{{ $item->comunicado }}</td>
                                        <td>{{ $item->titulo }}</td>
                                        <td>
                                            @if(count($item->fotos))
                                                <div
                                                    style="float: left; width: 100px; height: 100px; margin-right: 10px; background: url({{asset("storage/img/fotos/comunicados") . "/" . $item->fotos->first()->foto}}) 50% 50%; background-size: cover;">
                                                </div>
                                            @endif

                                        </td>
                                        <td>
                                            {{-- <div class="switch">
                                                <label>
                                                    <input type="checkbox" name="validado" class="check_status"
                                                     {{$item->status != "off" ? 'checked' :''}} >
                                                    <span class="lever"></span>
                                                </label>
                                            </div>   --}}

                                            <div class="switch">
                                                <label>
                                                <input type="checkbox" class="switch-status" data-id="{{$item->id}}" readOnly {{$item->status != "off" ? 'checked' :''}}>
                                                <span class="lever"></span>
                                                </label>
                                            </div>
                                        </td>
                                        <td>
                                            <div class="invoice-action">
                                              <a href="{{route('mcg.comunicados.edit',$item->id)}}" class="invoice-action-edit">
                                                <i class="material-icons">edit</i>
                                              </a>
                                              {!! Form::open(['route' => ['mcg.comunicados.destroy', $item->id], 'method'=>'DELETE','id' => $item->id]) !!}
                                                <a href="javascript:{}" onclick="eliminar({{ $item->id }})"><i class="material-icons">delete</i></a>
                                              {!! Form::close() !!}
                                            </div>
                                        </td>
                                    </tr>
                                @endforeach

                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
@endsection
@section('vendor-script')
<script src="{{asset('vendors/data-tables/js/jquery.dataTables.min.js')}}"></script>
<script src="{{asset('vendors/data-tables/extensions/responsive/js/dataTables.responsive.min.js')}}"></script>
<script src="{{asset('vendors/data-tables/js/dataTables.select.min.js')}}"></script>
<script src="{{asset('vendors/sweetalert/sweetalert.min.js')}}"></script>
@endsection
{{-- page script --}}
@section('page-script')
<script>
    $(document).ready(function() {
        $("#tableservicios").dataTable().fnDestroy();
        $('#tableservicios').DataTable({language:datatable_esp,"ordering": true,"order": [[ 0, 'desc' ]]});

        @if(session('deleteD') == 'ok')
            Swal.fire({
                title:  'Eliminado',
                text:  'Registro eliminado correctamente',
                icon: 'success',

            })
        @endif

        $(document).on("click", ".switch-status", function(){
        // console.log("hola")
                let id = $(this).data("id");
                let movimiento;
                let mensaje;
                if(!$(this).is(':checked')){
                     mensaje = "Al oprimir el botón de aceptar se desactivará el registro";
                     movimiento = 0;
                }else{
                    mensaje = "Al oprimir el botón de aceptar se activará el registro";
                    movimiento = 1;
                }
                // console.log(movimiento)
                // console.log(id)
                    Swal.fire({
                        title: "¿Está seguro?",
                        text: mensaje,
                        icon: 'warning',
                        showCancelButton: true,
                        confirmButtonColor: '#3085d6',
                        cancelButtonColor: '#d33',
                        confirmButtonText: 'Aceptar'
                    }).then((result) => {
                        if (result.isConfirmed) {
                                // id = id + "-" + movimiento
                                $.ajax ({
                                type: 'GET',
                                url :   "{{ url('mcg/validacionestatus') }}"+"/" + id + "/" + movimiento ,
                                    success:function(response){
                                        if(response.status == 200){
                                        Swal.fire({
                                            title:  'Status',
                                            text:  'Registro se actualizo correctamente',
                                            icon: 'success',
                                        })
                                    }
                                }
                            });

                        }
                    })



        });

    });



    function eliminar(id){
        Swal.fire({
            title: "¿Está seguro?",
            text: "Al oprimir el botón de aceptar se eliminará el registro",
            icon: 'warning',
            showCancelButton: true,
            confirmButtonColor: '#3085d6',
            cancelButtonColor: '#d33',
            confirmButtonText: 'Aceptar'
        }).then((result) => {
            if (result.isConfirmed) {
                document.getElementById(id).submit();

            }
        })

    }
</script>
@endsection

OHA YOOOO