@extends('Templates/templateAdmin')

@section('Main-content')
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-6">
                    <h1 class="text-light">Gestão de ativos</h1>
                </div>
                <div class="col-sm-6">
                    <ol class="breadcrumb float-sm-right">
                        <li class="breadcrumb-item active">Portefólio</li>
                        <li class="breadcrumb-item active">Gerir ativos</li>
                    </ol>
                </div><!-- /.col -->
            </div>
        </div><!-- /.container-fluid -->
    </section>

    <!-- /.content-header -->

    <!-- Main content -->
    <section class="content">
        <div class="container-fluid">
            <div class="row justify-content-center">
                <div class="col-md-12">
                    <form>
                        <div class="row">
                            <div class="col-sm-6" id="buttonCreateAssets">
                                <a href="#" type="button" class="btn btn-block bg-gradient-primary btn-lg">Criar
                                    ativos</a>

                            </div>
                            <div class="col-sm-6" id="buttonAssetsTable">
                                <a href="#" type="button" class="btn btn-block bg-gradient-primary btn-lg">Tabela de
                                    Ativos</a>
                            </div>
                        </div>
                    </form>

                    <br>

                    <div class="card-light" id="cardAssetsTable">
                        <div class="card-header">
                            <h3 class="card-title">Tabela de Ativos</h3>
                        </div>
                        <!-- /.card-header -->
                        <div class="card-body">
                            <div class="table-responsive">
                                <table class="table table-hover text-nowrap" id="assetsTable">
                                    <thead>
                                        <tr>
                                            <th>Tag</th>
                                            <th>Tipo Equipamento</th>
                                            <th>Fábricas</th>
                                            <th>Descrição Equipamento</th>
                                            <th>Ações</th>

                                        </tr>
                                    </thead>
                                    <tbody>
                                        @foreach ($equipments as $equipment)
                                            <tr>
                                                <td>{{ $equipment->equipment_tag }}</td>
                                                <td>{{ $equipment->equipmentType->equipment_type_name }}</td>
                                                <td>{{ $equipment->unit->unit_name }}</td>
                                                <td>{{ $equipment->equipment_description }}</td>
                                                <td>Ações</td>
                                            </tr>
                                        @endforeach
                                    </tbody>
                                </table>
                            </div>
                            <!-- /.card -->
                        </div>
                        <!-- /.card-body -->

                    </div>
                    {{-- ./cardAssetsTable --}}

                    <div class="card card-primary" id="cardCreateAssets">

                    </div>

                </div>
            </div>
    </section>
@endsection

@section('scriptsTemplateAdmin')
    <script>
        $(function() {
            $("#assetsTable").DataTable({
                "responsive": true,
                "lengthChange": false,
                "autoWidth": false,
                "buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
            }).buttons().container().appendTo('#assetsTable_wrapper .col-md-6:eq(0)');
        });
    </script>

    {{-- 
    <script type="text/javascript">
        $(document).ready(function() {
            // $('#cardAssetsTable').hide();
            $('#cardCreateAssets').hide();

            $('#receiveAllClients').on('change', function() {
                var receiveAllClients = $(this).val();
                console.log(receiveAllClients);
                if (receiveAllClients) {
                    $.ajax({
                        url: '/api/receivePlants/' + receiveAllClients,
                        type: 'GET',
                        success: function(data) {
                            console.log(data);
                        }
                    })
                }
            })
        })
    </script> --}}

    {{-- Script para DataTables Yajra --}}
    {{-- <script>
        $(document).ready(function() {
            $('#assetsTable').DataTable({
                autoWidth: false,
                processing: true,
                serverSide: true,
                ajax: {
                    url: '/api/receiveAllEquipments/',
                    // data: function(d) {
                    //     d.equipment_type_id = $('#tipo_valvulasList').val();
                    // },
                },
                columns: [{
                        data: 'equipment_tag',
                        name: 'equipment_tag'
                    },
                    // {
                    //     data: 'equipment_type',
                    //     name: 'equipment_type'
                    // },
                    // {
                    //     data: 'Unit',
                    //     name: 'Unit'
                    // },
                    {
                        data: 'equipment_description',
                        name: 'equipment_description'
                    },

                ],
                rowId: 'equipment_id'
            });
        })
    </script> --}}



    {{-- <script>
        $(function() {
            $('input[name="daterange"]').daterangepicker({
                opens: 'right'
            }, function(start, end, label) {
                console.log("A new date selection was made: " + start.format('YYYY-MM-DD') + ' to ' + end
                    .format('YYYY-MM-DD'));
            });
        });
    </script> --}}

    {{-- <script>
        $(function() {
            $("#TableEquipments").DataTable({
                "responsive": true,
                "lengthChange": false,
                "autoWidth": false,
                "buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
            }).buttons().container().appendTo('#TableEquipments_wrapper .col-md-6:eq(0)');
            $("#example1").DataTable({
                "responsive": true,
                "lengthChange": false,
                "autoWidth": false,
                "buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
            }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');
            $("#example2").DataTable({
                "responsive": true,
                "lengthChange": false,
                "autoWidth": false,
                "buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
            }).buttons().container().appendTo('#example2_wrapper .col-md-6:eq(0)');
            $("#example3").DataTable({
                "responsive": true,
                "lengthChange": false,
                "autoWidth": false,
                "buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"]
            }).buttons().container().appendTo('#example3_wrapper .col-md-6:eq(0)');
        });
    </script> --}}
@endsection
