@extends('layouts.admin')

@section('title')

  Pagine web

@stop

@section('content')

	   <div class="row">
      <div class="col-xs-12">
        <a href="{{ route('pages.create') }}" class="btn btn-success">Aggiungi</a>
      </div>
        <div class="col-xs-12">
          <div class="box">
            <div class="box-body">  
            <div class="box-body table-responsive no-padding">
              <table class="table table-striped table-hover" id="dtTable">
                <thead>
                <tr>
                  <th>Titolo</th>
                  <th>Online</th>
                  <th class="hidden-xs" width="50"></th>
                  <th class="hidden-xs" width="50"></th>
                  <th width="50"></th>
                </tr>
              </thead>
                @foreach($pages as $page)
                	<tr>
                    <td><a href="{{ route('pages.edit', array($page->id)) }}" >{{$page->title}}</a></td>
                    <td>{{$page->online ? 'Si' : 'No'}}</td>
                    <td class="hidden-xs">
                      <a href="{{ route('pages.advs.index', array($page->id)) }}" type="button" class="btn btn-w-m btn-primary">Pubblicità</a>
                    </td>
                    <td class="hidden-xs">
                        <a href="{{ route('pages.edit', array($page->id)) }}" type="button" class="btn btn-w-m btn-primary">Modifica</a>
                    </td>
                    <td>
                      <form class="form-inline" method="POST" action="{{ route('pages.destroy', $page->id) }}">
    @csrf
    @method('DELETE')
                          <button type="submit" class="btn btn-w-m btn-danger" onclick="return confirm('Sei sicuro?')">Elimina</button>
                      </form>
                    </td>
                	</tr>
                @endforeach
              </table>
            </div>

          </div>

        </div>
        <div class="col-xs-2">
          <a href="{{ route('pages.create') }}" class="btn btn-success">Aggiungi</a>
        </div>
        
      </div>
@stop


@section('extra_css')

  <link rel="stylesheet" href="/plugins/datatables/dataTables.bootstrap.css">
  <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/1.5.2/css/buttons.dataTables.min.css">

@stop

@section('extra_js')

  <script src="/plugins/datatables/jquery.dataTables.min.js"></script>
  <script src="/plugins/datatables/dataTables.bootstrap.min.js"></script>
  <script src="https://cdn.datatables.net/buttons/1.5.2/js/dataTables.buttons.min.js"></script>
  <script src="https://cdn.datatables.net/buttons/1.5.2/js/buttons.flash.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/pdfmake.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.36/vfs_fonts.js"></script>
  <script src="https://cdn.datatables.net/buttons/1.5.2/js/buttons.html5.min.js"></script>
  <script src="https://cdn.datatables.net/buttons/1.5.2/js/buttons.print.min.js"></script>

  <script type="text/javascript">
    
    $( document ).ready(function() {

      $("#dtTable").DataTable(
        {
          pageLength: 50,
          dom: 'Bfrtip',
          buttons: [
              /*'copy', 'csv', 'excel', 'pdf', 'print',
              {
                extend: 'pdfHtml5',
                orientation: 'landscape',
                pageSize: 'LEGAL'
              }*/
          ]
        },
        
      );
    });
  </script>

@stop