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

@extends('layouts/layoutMaster')

@section('title', 'Luoghi')

@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('pageTitle')
<div class="d-flex flex-column">
  <h4 class="mb-1">Luoghi</h4>
</div>
@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">
  <div class="col-xxl mb-4 mt-2">
    <div class="card">
      <div class="card-body">
        {{ $dataTable_luogo->table(['class' => 'table table-bordered']) }}
      </div>
    </div>
  </div>
</div>

@endsection

@section('page-script')

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


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

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

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

  });

</script>

<script>
  function initComplete_luogo(){
    $('div.dt-buttons button').removeClass('btn-secondary');
    return;
  }


</script>
@endsection
