effettuato modifiche per mappatura campi [BUG] non trova il file
This commit is contained in:
parent
097b7e922d
commit
0169ec6acd
@ -335,6 +335,22 @@ class MovimentiController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function importGenericCsv(Request $request)
|
||||
{
|
||||
if ($request->hasFile('filename'))
|
||||
{
|
||||
$filename=$request->file('filename')->store();
|
||||
$csv_headers=Movimenti::retrieveHeaders($filename);
|
||||
$db_fields=Movimenti::getDbFields();
|
||||
|
||||
return view('conti.importGeneric',['csv'=>$csv_headers,'db'=>$db_fields,'filename'=>$filename]);
|
||||
}
|
||||
|
||||
else {
|
||||
return 'Nessun File trovato';
|
||||
}
|
||||
}
|
||||
|
||||
public function importFile()
|
||||
{
|
||||
return view('conti.import');
|
||||
@ -345,6 +361,13 @@ class MovimentiController extends Controller
|
||||
return view('conti.importCR');
|
||||
}
|
||||
|
||||
public function importFileGen()
|
||||
{
|
||||
return view('conti.importGen');
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* public function test()
|
||||
{
|
||||
Movimenti::getYearsFromMovimenti();
|
||||
|
@ -5,10 +5,12 @@ namespace App\Models;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Rap2hpoutre\FastExcel\FastExcel;
|
||||
use App\Models\Categorie;
|
||||
use App\Models\Conto;
|
||||
use App\Models\User;
|
||||
//use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class Movimenti extends Model
|
||||
{
|
||||
@ -45,7 +47,7 @@ JOIN categories as c ON a.mov_fk_categoria=c.id';
|
||||
|
||||
public function Tags()
|
||||
{
|
||||
return $this->belongsTo(Tags::class);
|
||||
return $this->belongsTo(tag::class);
|
||||
}
|
||||
|
||||
public static function getList() {
|
||||
@ -242,7 +244,7 @@ JOIN categories as c ON a.mov_fk_categoria=c.id';
|
||||
public static function importEstrattoIng($filename)
|
||||
{
|
||||
|
||||
$inputPath='/var/www/html/gestionale_mt/public/storage/tenant'.tenant('id').'/'.$filename;
|
||||
$inputPath='/var/www/html/gestionale2025/storage/app/public/'.$filename;
|
||||
// $outputPath='/var/www/html/gestionale_mt/public/tenant'.tenant('id').'/import/'.$filename.'.csv';
|
||||
$outputPath = $inputPath.'.csv';
|
||||
rename($inputPath,$outputPath);
|
||||
@ -275,7 +277,7 @@ JOIN categories as c ON a.mov_fk_categoria=c.id';
|
||||
|
||||
public static function importEstrattoCR($filename)
|
||||
{
|
||||
$inputPath='/var/www/html/gestionale_mt/public/storage/tenant'.tenant('id').'/'.$filename;
|
||||
$inputPath='/var/www/html/gestionale2025/storage/app/public/'.$filename;
|
||||
// $outputPath='/var/www/html/gestionale_mt/public/'.tenant('id')."/app/".$filename;
|
||||
$outputPath = $inputPath.'.csv';
|
||||
rename($inputPath,$outputPath);
|
||||
@ -317,15 +319,27 @@ JOIN categories as c ON a.mov_fk_categoria=c.id';
|
||||
}
|
||||
|
||||
// Test filtri categoria
|
||||
public function mapFieldByName($name)
|
||||
public static function retrieveHeaders($filename)
|
||||
{
|
||||
// definisce lo schema per rigenerare il file CSV secondo standard di importazione
|
||||
$fields = Illuminate\Support\Facade\Schema::getColumnListing('movimentis')->mapFieldByName;
|
||||
foreach ($fields as $field)
|
||||
{
|
||||
echo $column . "\n";
|
||||
$inputPath= Storage::path($filename);
|
||||
$outputPath = $inputPath.'.csv';
|
||||
rename($inputPath,$outputPath);
|
||||
|
||||
$rows = (new FastExcel)->configureCsv(';')->import($outputPath);
|
||||
$headers = array_keys($rows->first());
|
||||
return $headers;
|
||||
}
|
||||
|
||||
public static function getDbFields()
|
||||
{
|
||||
return [
|
||||
"Data movimento"=>"mov_data",
|
||||
"Descrizione"=>"mov_descrizione",
|
||||
"Importo"=>"mov_importo",
|
||||
"Categoria"=>"mov_fk_categoria",
|
||||
"Tag"=>"mov_fk_tags",
|
||||
"Conto"=>"conto_id",
|
||||
];
|
||||
}
|
||||
|
||||
// Test applicazione regole
|
||||
|
@ -383,6 +383,11 @@ return [
|
||||
'text' => 'Importa Estratto conto Cassa Rurale',
|
||||
'route' => 'importCR',
|
||||
],
|
||||
[
|
||||
'text' => 'Importa Generic CSV',
|
||||
'route' => 'importGen',
|
||||
],
|
||||
|
||||
],
|
||||
],
|
||||
],
|
||||
|
27
resources/views/conti/importGen.blade.php
Normal file
27
resources/views/conti/importGen.blade.php
Normal file
@ -0,0 +1,27 @@
|
||||
@extends('adminlte::page')
|
||||
|
||||
@section('content_header')
|
||||
<h1>Importazione Estratto conto Generico</h1>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
|
||||
<div class="container">
|
||||
<!-- Content here -->
|
||||
<div class="row">
|
||||
<div class="col-lg-10">
|
||||
<form action="" method="POST" enctype='multipart/form-data'>
|
||||
@csrf
|
||||
<div class="mb-3">
|
||||
<label for="file" class="form-label">File</label>
|
||||
<input type="file" class="form-control" id="file" name="filename">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@endsection
|
25
resources/views/conti/importGeneric.blade.php
Normal file
25
resources/views/conti/importGeneric.blade.php
Normal file
@ -0,0 +1,25 @@
|
||||
@extends('adminlte::page')
|
||||
|
||||
@section('content_header')
|
||||
<h3> Mappa i campi </h3>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<form action="" method="POST">
|
||||
@csrf
|
||||
@foreach ($csv as $header)
|
||||
<label>{{ $header }}</label>
|
||||
<select name="mapping[{{ $header }}]">
|
||||
<option value="">--Nessuno o Selezionare una colonna--</option>
|
||||
<option value="mov_data">Data Movimento</option>
|
||||
<option value="mov_desc">Descrizione</option>
|
||||
<option value="mov_importo">Importo</option>
|
||||
<option value="mov_fk_categoria">ID Categoria</option>
|
||||
<option value="mov_fk_tag">ID Tag</option>
|
||||
<option value="mov_fk_conto">ID Conto</option>
|
||||
</select>
|
||||
@endforeach
|
||||
<input type="hidden" name="filename" value="{{ $filename }}">
|
||||
<button type="submit">Salva</button>
|
||||
</form>
|
||||
@endsection
|
@ -94,6 +94,8 @@ Route::middleware([
|
||||
Route::post('admin/movimenti/import', [MovimentiController::class,'importEC_ING']);
|
||||
Route::get('admin/movimenti/importcr', [MovimentiController::class,'importFileCR'])->name('importCR');
|
||||
Route::post('admin/movimenti/importcr', [MovimentiController::class,'importEC_CR']);
|
||||
Route::get('admin/movimenti/importgen', [MovimentiController::class,'importFileGen'])->name('importGen');
|
||||
Route::post('admin/movimenti/importgen', [MovimentiController::class,'importGenericCsv']);
|
||||
Route::get('/admin/movimenti/giroconto', [MovimentiController::class,'giroconto'])->name('giroconto');
|
||||
Route::post('/admin/movimenti/giroconto', [MovimentiController::class,'girocontoPost']);
|
||||
|
||||
@ -264,3 +266,4 @@ Route::middleware('auth:sanctum')->group(function () {
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user