<?php
use App\Models\Role;
use Illuminate\Support\Facades\Auth;
?>
@php
$configData = Helper::appClasses();
@endphp

@extends('layouts/layoutMaster')

@section('title', 'Configurazioni segnalazioni')

@section('vendor-style')
@vite([
'resources/assets/vendor/libs/datatables-bs5/datatables.bootstrap5.scss',
'resources/assets/vendor/libs/datatables-responsive-bs5/responsive.bootstrap5.scss',
'resources/assets/vendor/libs/datatables-buttons-bs5/buttons.bootstrap5.scss',
'resources/assets/vendor/libs/flatpickr/flatpickr.scss',
'resources/assets/vendor/libs/@form-validation/form-validation.scss'
])
@endsection

<!-- Vendor Scripts -->
@section('vendor-script')
@vite([
'resources/assets/vendor/libs/moment/moment.js',
'resources/assets/vendor/libs/flatpickr/flatpickr.js',
'resources/assets/vendor/libs/@form-validation/popular.js',
'resources/assets/vendor/libs/@form-validation/bootstrap5.js',
'resources/assets/vendor/libs/@form-validation/auto-focus.js',
'resources/assets/vendor/libs/@form-validation/popular.js',
'resources/assets/vendor/libs/@form-validation/bootstrap5.js',
'resources/assets/vendor/libs/@form-validation/auto-focus.js',
'resources/assets/vendor/libs/datatables-bs5/datatables-bootstrap5.js'
])
@endsection

@section('content')
<style>
  div.upload button:first-child{
    display: none !important;
  }
</style>

@if(session('status'))
<div class="alert alert-success">
  {{ session('status') }}
</div>
@endif

<div class="row justify-content-center">
  <h4 class="mb-1">Configurazioni segnalazioni</h4>
  <p class="mb-0">Lista di tutte le configurazioni delle segnalazioni</p>
  <div class="col-xxl mb-4 mt-2">
    <div class="card">
      <div class="card-body">
        {{ $dataTable_configurasegnalazione->table(['class' => 'table table-bordered']) }}
      </div>
    </div>
  </div>
</div>

@endsection

@section('page-script')

{{$dataTable_configurasegnalazione->scripts(attributes: ['type' => 'module'])}}


<script type="module">
  $(document).ready(function(){
    // Editor edit
    $("#dataTable_configurasegnalazione").on('click', 'a.editor_edit', function (e) {
      e.preventDefault();
      window.LaravelDataTables["dataTable_configurasegnalazione-editor"].edit( $(this).closest('tr'), {
        title: 'Modifica',
        buttons: 'Aggiorna',
      });
    });

    // Editor delete
    $("#dataTable_configurasegnalazione").on('click', 'a.editor_delete', function (e) {
      e.preventDefault();
      window.LaravelDataTables["dataTable_configurasegnalazione-editor"].remove($(this).closest('tr'), {
        title: 'Cancella record',
        message: 'Sei sicuro di voler eliminare il record selezionato?',
        buttons: 'Cancella record'
      });
    } );

    $("#dataTable_configurasegnalazione").on('dblclick', 'tbody td', function (e) {
      window.LaravelDataTables["dataTable_configurasegnalazione-editor"].edit( $(this).closest('tr'), {
        title: 'Modifica',
        buttons: 'Aggiorna',
      });
    });

  });

</script>

<script>
  function initComplete_configurasegnalazione(){
    $('div.dt-buttons button').removeClass('btn-secondary');
    return;
    // const thead = document.querySelector('#dataTable_reparto thead');
    // const cloneRow = thead.querySelector('tr').cloneNode(true);
    // thead.appendChild(cloneRow);

    // $('#dataTable_reparto thead tr:nth-child(2) th').each( function (i) {
    //   $(this).unbind();
    //   switch(i){
    //     case 0: // nome
    //     $(this).html("<input type='text' class='form-control' placeholder='Cerca "+$(this).text()+"' />");
    //     break;

    //     default:
    //     $(this).html( "" );
    //     break;
    //   }

    //   // Faccio il parse del testo inserito dall'utente prima di filtrarlo

    //   $( 'input, select', this ).on( 'keyup change', function () {
    //     if(this.value == ""){
    //       window.LaravelDataTables["dataTable_gruppo"].columns().search('').draw();
    //     }else{
    //       if (window.LaravelDataTables["dataTable_gruppo"].column(i).search() !== this.value){
    //         valore_filtro = this.value;
    //         switch(i){
    //           default:
    //           valore_filtro = this.value;
    //           break;
    //         }
    //         window.LaravelDataTables["dataTable_gruppo"].column(i).search( valore_filtro ).draw();
    //       }
    //     }
    //   });
    // });
  }


</script>
@endsection
