@extends('layouts.admin')

@section('title')

  News

@stop

@section('content')



	   <div class="row">
      
      <div class="col-xs-12">
        <a href="{{ route('news.crop') }}" class="btn btn-success">Aggiungi</a>
        <!--<a href="{{ route('news.create') }}" class="btn btn-success">Aggiungi breaking news</a><br><br>-->
      </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>Data</th>
                  <th>Immagine</th>
                  <th>Titolo</th>
                  <th class="hidden-xs">Sezione</th>
                  <th class="hidden-xs">Regione 1</th>
                  <th class="hidden-xs">Regione 2</th>
                  <th class="hidden-xs">Online</th>
                  
                  <th class="hidden-xs">Clicks</th>
                  <th class="hidden-xs" width="50"></th>
                  <th class="hidden-xs" width="50"></th>
                  <th class="hidden-xs" width="50"></th>
                </tr>
              </thead>
                
              </table>
            </div>

          </div>

        </div>
        
        
      </div>
      <div class="col-xs-2">
        <a href="{{ route('news.crop') }}" 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 src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>

  <script type="text/javascript">
    
    $( document ).ready(function() {
      $("#dtTable").DataTable(
        {
          stateSave: true,
          /*"stateSaveParams": function (settings, data) {
            data.search.search = "";
          },*/
          paging: true,
          "pageLength": 50,
          dom: 'Bfrtip',
          order: [[0, 'desc']],
          buttons: [
              /*'copy', 'csv', 'excel', 'pdf', 'print',
              {
                extend: 'pdfHtml5',
                orientation: 'landscape',
                pageSize: 'LEGAL'
              }*/
          ],
          processing: true,
          serverSide: true,
          "ajax": "/admin/news/load_json",
          "createdRow": function( row, data, dataIndex){
            if( data[6].substr(3, 2) == 'si')
            {
              $(row).css("background-color", "#bff250");
            }
            else
            {
              $(row).css("background-color", "#f7d386");
            }
          },
          columnDefs:[{targets:0, render:function(data){
            return moment(data).format('DD/MM/YYYY HH:mm');
          }}]
        },
        
      );      
      $('#dtTable').on( 'page.dt', function () {
        $('html, body').animate({
            scrollTop: 0
        }, 300);
    } );
    });

  </script>

@stop