ispt4.0_laravel/resources/views/createProjectExcel.blade.php
2023-08-01 15:20:39 +01:00

180 lines
6.3 KiB
PHP
Executable File

@extends('Templates/templateAdmin')
@section('Main-content')
<!-- Content Header (Page header) -->
<!-- /.content-header -->
@if (session('success'))
<div class="alert alert-success" role="alert">
{{ session('success') }}
</div>
@endif
{{-- <meta name="csrf-token" content="{{ csrf_token() }}"> --}}
<br><br>
<div class="card">
<div class="card-body">
<div class="container mt-5">
<div class="card "></div>
<form action="{{ route('createEquipamentProject') }}" method="post" enctype="multipart/form-data">
@csrf
<div class="form-group">
<label for="inputDocumento">Selecione um documento:</label>
<input type="file" class="form-control-file" id="inputDocumento" name="documento" accept=".xlsx, .xls">
</div>
<button type="submit" class="btn btn-primary">Enviar</button>
</form>
<div class="form-group col-sm-6">
<label for="exampleInputFile">Import Articulated </label>
<div class="input-group">
<div class="custom-file">
<input type="file" class="custom-file-input"
id="exampleInputFile">
<label class="custom-file-label"for="exampleInputFile">
Choose File</label>
</div>
</div>
</div>
<br><br>
<a id="btn-download-template" href="{{ route('download') }}" class="btn btn-warning">Baixar Template</a>
</div>
<table class="table table-bordered">
<thead>
<tr>
<th>ID</th>
<th>Fabrica</th>
<th>Tipo de Equipamento</th>
<th>Tag</th>
<th>Descricao Equipamento</th>
<th>Numero de Serie</th>
<th>Marca</th>
<th>Modelo</th>
<th>Editar</th>
</tr>
</thead>
<tbody>
@if(Session::has('listValves'))
@foreach(Session::get('listValves') as $valve)
<tr>
<td>{{ $valve->equipment_id }}</td>
<td>{{ $valve->unit_id }}</td>
<td>{{ $valve->equipment_type_id }}</td>
<td>{{ $valve->equipment_tag }}</td>
<td>{{ $valve->equipment_description }}</td>
<td>{{ $valve->equipment_serial_number }}</td>
<td>{{ $valve->equipment_brand }}</td>
<td>{{ $valve->equipment_model }}</td>
<td>Botoes Editar</td>
{{-- <td>{{ $valve->Is_active }}</td> --}}
</tr>
@endforeach
@endif
</tbody>
</table>
</div>
</div>
{{-- <div class="card">
<div class="card-body">
<div class="container mt-5">
<form>
@csrf
<div class="form-group">
<label for="inputDocumento">Selecione um documento:</label>
<input type="file" class="form-control-file" id="inputDocumento" accept=".xlsx, .xls">
</div>
<button type="submit" class="btn btn-primary">Enviar</button>
</form>
<br><br>
<a id="btn-download-template" href="{{ route('download') }}" class="btn btn-warning">Baixar Template</a>
<div id="tabelaExcel" class="mt-5" style="display: none;"></div>
</div>
</div>
</div> --}}
{{-- <script>
const downloadUrl = "{{ route('download') }}";
document.getElementById('btn-download-template').setAttribute('formaction', downloadUrl);
(function() {
const tabelaExcel1 = document.getElementById('tabelaExcel1');
function handleFormSubmit(event) {
event.preventDefault();
const inputFile = document.getElementById('inputDocumento').files[0];
const reader = new FileReader();
reader.readAsBinaryString(inputFile);
reader.onload = function() {
const fileData = reader.result;
const workbook = XLSX.read(fileData, {
type: 'binary'
});
const worksheet1 = workbook.Sheets[workbook.SheetNames[0]];
const tableData1 = XLSX.utils.sheet_to_json(worksheet1);
const slicedData = tableData1.slice(3);
$.ajax({
url: "{{ route('createEquipamentProject') }}",
method: 'POST',
data: {
data: slicedData
},
success: function(response) {
if (response.success) {
// A criação foi bem-sucedida
console.log("A criação dos equipamentos foi bem-sucedida!");
document.getElementById('tabelaExcel').style.display = 'block';
} else {
// A criação falhou
console.log("A criação dos equipamentos falhou.");
}
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(textStatus, errorThrown);
}
});
}
}
const form = document.querySelector('form');
form.addEventListener('submit', handleFormSubmit);
})();
</script> --}}
@endsection