@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>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 card-primary" id="cardAssetsTable">
                        <div class="card-header">
                            <h3 class="card-title">Tabela de Ativos</h3>
                        </div>
                        <!-- /.card-header -->
                        <div class="card-body">

                            {{-- <div class="row text-center">

                                <div class="form-group col-sm-3">
                                    <label>Cliente </label>
                                    <select id="receiveAllClients" name="receiveAllClients" class="form-control">
                                        <option value='all' selected>Mostrar Todos</option>
                                        @foreach ($allClients as $client)
                                            <option value="{{ $client->user_id }}">
                                                {{ $client->user_name }}</option>
                                        @endforeach
                                    </select>
                                </div>

                                <div class="form-group col-sm-3">
                                    <label>Instalações </label>
                                    <select id="receivePlantClientRelated" name="receivePlantClientRelated"
                                        class="form-control">
                                        <option value='#' selected>Mostrar Todas</option>
                                    </select>
                                </div>

                                <div class="col-sm-3">
                                    <div class="form-group">
                                        <label>Fábricas </label>
                                        <select id="receiveUnitsClientRelated" name="receiveUnitsClientRelated"
                                            class="form-control">
                                            <option value='#' selected>Mostrar Todos</option>
                                        </select>
                                    </div>
                                </div>

                                <div class="form-group col-sm-3">
                                    <label>Tipo de Equipamento </label>
                                    <select id="tipo_valvulasList" name="equipmentTypeId" class="form-control">
                                        <option value='#' selected>Mostrar Todos</option>
                                        @foreach ($allEquipmentType as $equipmentsType)
                                            <option value="{{ $equipmentsType->equipment_type_id }}">
                                                {{ $equipmentsType->equipment_type_name }}</option>
                                        @endforeach
                                    </select>
                                </div>

                            </div> --}}

                            <div class="table-responsive">
                                {{-- Tabela para se usar com DataTables Yajra --}}
                                {{-- <table id="assetsTable" class="table table-bordered table-striped">
                                    <thead>
                                        <tr>
                                            <th>Tag</th>
                                            <th>Tipo Equipamento</th>
                                            <th>Fábricas</th>
                                            <th>Descrição Equipamento</th>
                                        </tr>
                                    </thead>
                                </table> --}}

                                <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>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        @foreach ($equipments as $equipment)
                                            <tr>
                                                <td>{{ $equipment->equipment_tag }}</td>

                                            </tr>
                                        @endforeach
                                    </tbody>

                            </div>
                            <!--/articulado de obra-->
                            <!-- /.card-body -->
                            {{-- <div class="card-footer">
                                    <div class="float-right">
                                        <button type="button" class="btn btn-primary" data-toggle="modal"
                                            data-target="#ModalTransferForArticulated">
                                            Editar
                                        </button>
                                    </div>
                                </div> --}}


                            <!-- modal Remover -->
                            {{-- <div class="modal fade" id="modal-ViewOfices">
                                <div class="modal-dialog modal-xl">
                                    <div class="modal-content">
                                        <div class="modal-header bg-primary">
                                            <h4 class="modal-title">Posto de Trabalho X</h4>
                                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                <span aria-hidden="true">x</span>
                                            </button>
                                        </div>
                                        <div class="modal-body">
                                            <section class="content">
                                                <div class="container-fluid">
                                                    <div class="row text-center">
                                                        <div class="col-sm-6">
                                                            <div class="card card-success">
                                                                <div class="card-header">
                                                                    <h3 class="card-title">
                                                                        Tarefas Elementares PSV</h3>
                                                                    <div class="card-tools">
                                                                        <button type="button" class="btn btn-tool"
                                                                            data-card-widget="collapse"><i
                                                                                class="fas fa-minus"></i>
                                                                        </button>
                                                                    </div>
                                                                </div>
                                                                <div class="card-body">
                                                                    <!-- Tabela de Checkbox -->
                                                                    <div>
                                                                        <p>TE1 - Desmontar da linha
                                                                            <input type="checkbox"
                                                                                class="checkboxChoseTasksOficesPSV"
                                                                                value="TE1">
                                                                        </p>
                                                                        <p>TE2 - Descontaminar
                                                                            <input type="checkbox"
                                                                                class="checkboxChoseTasksOficesPSV"
                                                                                value="TE2" checked>
                                                                        </p>
                                                                        <p>TE3 - Pré-teste
                                                                            <input type="checkbox"
                                                                                class="checkboxChoseTasksOficesPSV"
                                                                                value="TE3">
                                                                        </p>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>

                                                        <div class="col-sm-6">
                                                            <div class="card card-primary">
                                                                <div class="card-header">
                                                                    <h3 class="card-title">
                                                                        Tarefas Elementares ISV</h3>
                                                                    <div class="card-tools">
                                                                        <button type="button" class="btn btn-tool"
                                                                            data-card-widget="collapse"><i
                                                                                class="fas fa-minus"></i>
                                                                        </button>
                                                                    </div>
                                                                </div>
                                                                <div class="card-body">
                                                                    <!-- Tabela de Checkbox -->
                                                                    <div>
                                                                        <p>TE1 - Desmontar da linha
                                                                            <input type="checkbox"
                                                                                class="checkboxChoseTasksOficesISV"
                                                                                value="TE1">
                                                                        </p>
                                                                        <p>TE2 - Descontaminar
                                                                            <input type="checkbox"
                                                                                class="checkboxChoseTasksOficesISV"
                                                                                value="TE2">
                                                                        </p>
                                                                        <p>TE5 - Limpeza e lavagem
                                                                            dos componentes
                                                                            <input type="checkbox"
                                                                                class="checkboxChoseTasksOficesISV"
                                                                                value="TE5">
                                                                        </p>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>

                                                        <!-- Divisória Para Metade -->
                                                        <div class="col-sm-6">
                                                            <div class="card card-warning">
                                                                <div class="card-header">
                                                                    <h3 class="card-title">
                                                                        Tarefas Elementares CV</h3>
                                                                    <div class="card-tools">
                                                                        <button type="button" class="btn btn-tool"
                                                                            data-card-widget="collapse"><i
                                                                                class="fas fa-minus"></i>
                                                                        </button>
                                                                    </div>
                                                                </div>
                                                                <div class="card-body">
                                                                    <!-- Tabela de Checkbox -->
                                                                    <div>
                                                                        <p>TE12 - Inspeção visual
                                                                            <input type="checkbox"
                                                                                class="checkboxChoseTasksOficesCV"
                                                                                value="TE12" checked>
                                                                        </p>
                                                                        <p>TE1 - Desmontar da linha
                                                                            <input type="checkbox"
                                                                                class="checkboxChoseTasksOficesCV"
                                                                                value="TE1">
                                                                        </p>
                                                                        <p>TE14 - Ensaio
                                                                            <input type="checkbox"
                                                                                class="checkboxChoseTasksOficesCV"
                                                                                value="TE14">
                                                                        </p>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>

                                                        <div class="col-sm-6">
                                                            <div class="card card-info collapsed-card">
                                                                <div class="card-header">
                                                                    <h3 class="card-title">
                                                                        Outras Tarefas</h3>
                                                                    <div class="card-tools">
                                                                        <button type="button" class="btn btn-tool"
                                                                            data-card-widget="collapse">
                                                                            <i class="fas fa-plus"></i>
                                                                        </button>
                                                                    </div>
                                                                </div>
                                                                <div class="card-body">
                                                                    <!-- Tabela de Checkbox -->
                                                                    <div>
                                                                        <p>TE1 - Desmontar da linha
                                                                            <input type="checkbox" id="">
                                                                        </p>
                                                                        <p>TE12 - Inspeção visual
                                                                            <input type="checkbox" id="">
                                                                        </p>
                                                                        <p>TE14 - Ensaio
                                                                            <input type="checkbox" id="">
                                                                        </p>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>

                                                    </div>
                                                </div>
                                            </section>
                                            <!-- Tabelas das Tarefas selecionadas -->
                                            <div class="card">
                                                <h3>Tarefas Selecionadas para o Postos X:</h3>
                                                <div class="row">
                                                    <div class="col-sm-4 text-center"
                                                        id="ReceiveCheckboxChoseTasksOficesPSV">
                                                    </div>
                                                    <div class="col-sm-4 text-center"
                                                        id="ReceiveCheckboxChoseTasksOficesCV">
                                                    </div>
                                                    <div class="col-sm-4 text-center"
                                                        id="ReceiveCheckboxChoseTasksOficesISV">
                                                    </div>
                                                </div>
                                            </div>

                                            <div class="modal-footer justify-content-between">
                                                <!-- Vai ficar o Footer -->
                                                <button class="btn btn-danger">Cancelar</button>
                                                <button class="btn btn-primary">Guardar</button>
                                            </div>
                                        </div>
                                        <!-- /.modal-content --
                                                                                 /.modal-dialog -->
                                    </div>
                                    <!-- /.modal remover-->

                                </div>
                                <!-- /.Modal, Postos de Trabalho -->
                            </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
