<?php 
use Carbon\Carbon;
?>

<?php $__env->startSection('content'); ?>

<section class="content-header">
                <h1>Intervento</h1>
                <ol class="breadcrumb">
                    <li>
                        <a href="<?php echo e(route('home')); ?>">
                            <i class="livicon" data-name="home" data-size="14" data-color="#000"></i>
                            Home
                        </a>
                    </li>
                    <li>
                        <a href="<?php echo e(URL::to('intervento')); ?>">
                            Intervento
                        </a>
                    </li>
                    <li class="active">Lista</li>
                </ol>
            </section>
            <section class="content">

<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
    <?php if(Session::has('ok_message')): ?>
        <div class="alert alert-success"><?php echo e(Session::get('ok_message')); ?></div>
    <?php endif; ?>

    <label>
        <a class="btn btn-success" href="/intervento/create"><span class="glyphicon glyphicon-plus-sign"></span> Aggiungi</a>
    </label>
    
    <table id="table1" class="table1 table-bordered">
        <thead>
        <tr>
            <th>Anno</th>
            <th>Numero</th>
            <th>Data inserimento ticket</th>
            <th>Numero ticket cliente</th>
            <th>Sede intervento</th>
            <th>Cliente</th>
            <th>Intervento tipo</th>
            <th>Intervento stato</th>
            <th>Azioni</th>
        </tr>
        </thead>

        <tbody>
            <?php
/*            
            @foreach($listaIntervento as $ln)
            <tr>
            <td>{{$ln['anno']}}</td>
            <td>{{$ln['numero']}}</td>
            <td><?php echo Carbon::createFromFormat('Y-m-d', $ln['data_inserimento_ticket'])->format('d/m/Y');?></td>
            <td>{{$ln['numero_ticket_cliente']}}</td>
            <td>{{$ln['sede_intervento']}}</td>
            <td>{{-- $ln['cliente_id'] --}} 
                
                @if(!is_null($ln->cliente)) 
                    {{{$ln->cliente->ragione_sociale}}}
                @endif
            
            </td>
            <td>{{$ln['intervento_tipo']}}</td>
            <td>{{$ln['intervento_stato']}}</td>
            <td>
                
                <a class="btn btn-sm btn-info" href="/intervento/{{$ln['id']}}" title="Visualizza"><span class="glyphicon glyphicon-search"></span></a>
                <a class="btn btn-sm btn-warning" href="/intervento/{{$ln['id']}}/edit" title="Modifica"><span class="glyphicon glyphicon-edit"></span></a>
                
            {!! Form::open([
                'method' => 'DELETE',
                'route' => ['intervento.destroy', $ln['id']],
                'onsubmit' => 'return confirm("Sei sicuro di eliminare il record?");',
                'style' => 'display: inline'
                
            ]) !!}
            <button class="btn btn-sm btn-danger" title="Cancella"><span class="glyphicon glyphicon-remove"></span></button>
            {!! Form::close() !!}                

            </td>
            </tr>
            @endforeach
 * 
 */
            ?>
        </tbody>
    </table>
</div>
                
            </section>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('footer_scripts'); ?>
<script>
 $(function() {
//            <th>Anno</th>
//            <th>Numero</th>
//            <th>Data inserimento ticket</th>
//            <th>Numero ticket cliente</th>
//            <th>Sede intervento</th>
//            <th>Cliente</th>
//            <th>Intervento tipo</th>
//            <th>Intervento stato</th>
//            <th>Azioni</th>     
            var table = $('#table1').DataTable({
                processing: true,
                serverSide: true,
                ajax: '<?php echo route('intervento.data'); ?>',
                columns: [
                    { data: 'anno', name: 'interventi.anno' },
                    { data: 'numero', name: 'interventi.numero' },
                    { data: 'data_inserimento_ticket', name: 'interventi.data_inserimento_ticket' },
                    { data: 'numero_ticket_cliente', name: 'interventi.numero_ticket_cliente' },
                    { data: 'sede_intervento', name: 'interventi.numero_ticket_cliente' },
                    { data: 'ragione_sociale', name: 'anagrafica.ragione_sociale' },
                    { data: 'interventi_tipo.nome', name: 'interventi_tipo.nome' },
                    { data: 'nome', name: 'interventi_stato.nome' },
                    { data: 'actions', name: 'actions', orderable: false, searchable: false }
                ]
            });
            table.on( 'draw', function () {
                $('.livicon').each(function(){
                    $(this).updateLivicon();
                });
            } );
        });    
</script>
<?php $__env->appendSection(); ?>
<?php echo $__env->make('layouts.main', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>