<?php

use Illuminate\Support\Facades\Auth;
?>

@extends('layouts/layoutMaster')

@section('title', 'Segnalazioni')

@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',
'resources/assets/vendor/libs/datatables-bs5/datatables-bootstrap5.js'
])
@endsection

@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',
'resources/assets/vendor/libs/datatables-rowgroup-bs5/rowgroup.bootstrap5.scss'
])
@endsection

@section('pageTitle')
<div class="d-flex flex-column">
  <h4 class="mb-1">Segnalazioni {{ $status ? '(' . ucfirst(str_replace('_', ' ', $status)) . ')' : '' }}</h4>
</div>
@endsection

@section('content')
{{-- <div class="row justify-content-center">
  <h4 class="mb-1"></h4>
  <p class="mb-0">Lista di tutte le segnalazioni</p>
</div> --}}

<div class="col-xxl mb-4 mt-2">

  @if(session('success'))
  <div class="alert alert-success alert-dismissible fade show" role="alert">
    <i class="bx bx-check-circle me-2"></i>
    {{ session('success') }}
    <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
  </div>
  @endif

  @if(session('error'))
  <div class="alert alert-danger alert-dismissible fade show" role="alert">
    <i class="bx bx-error-circle me-2"></i>
    {{ session('error') }}
    <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
  </div>
  @endif


  <div class="card">
    <div class="card-body">
      {{ $dataTable_segnalazione->table() }}
    </div>
  </div>
</div>

@endsection

@section('page-style')
<style>
  /* Badge label style - Testo sempre visibile */
  .badge.badge-hover-label,
  div.badge.badge-hover-label {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    white-space: nowrap !important;
    position: relative !important;
  }

  .badge.badge-hover-label .badge-label-text,
  div.badge.badge-hover-label .badge-label-text,
  .badge.badge-hover-label span.badge-label-text,
  div.badge.badge-hover-label span.badge-label-text {
    max-width: none !important;
    max-width: 500px !important;
    opacity: 1 !important;
    visibility: visible !important;
    overflow: visible !important;
    margin-left: 0.5rem !important;
    display: inline-block !important;
    width: auto !important;
  }

  .badge.badge-hover-label .icon-base,
  div.badge.badge-hover-label .icon-base {
    flex-shrink: 0 !important;
    display: inline-block !important;
  }
</style>
@endsection

@section('page-script')
{{ $dataTable_segnalazione->scripts(attributes: ['type' => 'module']) }}


<script type="module">

  $(document).ready(function(){
    $.ajaxSetup({
      headers: {
        'X-CSRF-TOKEN': '{{csrf_token()}}'
      }
    });

    $("#dataTable_segnalazione").on('dblclick', 'tbody td', function () {
      window.location.href = "{{ route('admin.segnalazione.show') }}?id=" + $(this).closest('tr').attr('id');
    });

    $("#dataTable_segnalazione").on('click', 'a.editor_delete', function (e) {
      e.preventDefault();
      editor.remove($(this).closest('tr'), {
        title: 'Cancella record',
        message: 'Sei sicuro di voler eliminare il record selezionato?',
        buttons: 'Cancella record'
      });
    });

  });
</script>

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