Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
9320ce76a1 | |||
f82f65a0c5 | |||
652f9a7e76 | |||
a1742e4e61 | |||
0ca16a6969 | |||
0169ec6acd |
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Categorie;
|
||||
use App\Models\ImportRule;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@ -13,6 +14,8 @@ class ImportRuleController extends Controller
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
$rules = ImportRule::all();
|
||||
return view('import_rules.index', compact('rules'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -21,6 +24,11 @@ class ImportRuleController extends Controller
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
// Return a view to create a new import rule
|
||||
|
||||
$categorie = Categorie::all();
|
||||
return view('import_rules.create',compact('categorie'));
|
||||
//'categories'=>$categorie);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -29,6 +37,23 @@ class ImportRuleController extends Controller
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
$request->validate([
|
||||
'pattern' => 'required|string|max:255',
|
||||
'category_id' => 'required|exists:categories,id',
|
||||
'description' => 'nullable|string|max:255',
|
||||
'is_active' => 'boolean',
|
||||
'created_by' => 'nullable|string|max:255',
|
||||
]);
|
||||
ImportRule::create(
|
||||
[
|
||||
'category_id'=>$request->category_id,
|
||||
'pattern'=>$request->pattern,
|
||||
'description'=>$request->description,
|
||||
'is_active'=>1,
|
||||
]
|
||||
|
||||
);
|
||||
return redirect()->route('import_rules.index'); // Redirect to the index after storing the rule
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -13,9 +13,14 @@ use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Rap2hpoutre\FastExcel\FastExcel;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use DateTime;
|
||||
|
||||
|
||||
class MovimentiController extends Controller
|
||||
{
|
||||
public $map;
|
||||
|
||||
// Gestione dei movimenti
|
||||
public static function newMovimenti() {
|
||||
$categorie=Categorie::list(); // TODO: da risolvere con jquery nella pagina blade conti.movimenti.list
|
||||
@ -335,6 +340,83 @@ 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 importmappedCsv(Request $request)
|
||||
{
|
||||
$this->prepareMapping($request['mapping']);
|
||||
$filename = Storage::path($request->filename);
|
||||
|
||||
(new FastExcel)->configureCsv(';')->import($filename, function($line) {
|
||||
$data = $this->mapCsvLineToDb($line);
|
||||
// dd($data);
|
||||
if (isset($data['mov_data'])) {
|
||||
Movimenti::create($data);
|
||||
}
|
||||
});
|
||||
|
||||
return redirect(Route('movimenti'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepara la mappatura tra i campi CSV e i campi DB
|
||||
*/
|
||||
private function prepareMapping($mapping)
|
||||
{
|
||||
foreach ($mapping as $key => $value) {
|
||||
if ($value != null) {
|
||||
$this->map[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Mappa una riga del CSV ai campi del database
|
||||
*/
|
||||
private function mapCsvLineToDb($line)
|
||||
{
|
||||
if (isset($line[$this->map['mov_data']])) {
|
||||
$data = [
|
||||
'mov_data' => $this->parseDate($line[$this->map['mov_data']]),
|
||||
'mov_descrizione' => $line[$this->map['mov_descrizione']] ?? null,
|
||||
'mov_importo_dare' => Movimenti::cleanImporto($line[$this->map['mov_importo_dare']]?? null) ,
|
||||
'mov_importo_avere' => Movimenti::cleanImporto($line[$this->map['mov_importo_avere']] ?? null),
|
||||
'mov_fk_categoria' => Movimenti::setCategoriesFromCsv($line[$this->map['mov_descrizione']] ?? ''),
|
||||
'mov_fk_tags' => 1,
|
||||
'mov_inserito_da' => Auth::id(),
|
||||
'conto_id_da' => 1,
|
||||
'conto_id_a' => 1,
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
return null; // Se non c'è la data, non importa la riga
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Converte la data dal formato d/m/Y a Y-m-d
|
||||
*/
|
||||
private function parseDate($dateString)
|
||||
{
|
||||
$date = DateTime::createFromFormat('d/m/Y', $dateString);
|
||||
return $date ? $date->format('Y-m-d') : null;
|
||||
}
|
||||
|
||||
public function importFile()
|
||||
{
|
||||
return view('conti.import');
|
||||
@ -345,6 +427,13 @@ class MovimentiController extends Controller
|
||||
return view('conti.importCR');
|
||||
}
|
||||
|
||||
public function importFileGen()
|
||||
{
|
||||
return view('conti.importGen');
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* public function test()
|
||||
{
|
||||
Movimenti::getYearsFromMovimenti();
|
||||
@ -360,4 +449,5 @@ class MovimentiController extends Controller
|
||||
$mov=Movimenti::getMovimentoById($id);
|
||||
return json_encode($mov);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,4 +8,14 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class ImportRule extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $fillable = [
|
||||
'category_id',
|
||||
'pattern',
|
||||
'description',
|
||||
'is_active',
|
||||
'created_by',
|
||||
];
|
||||
|
||||
// In MovimentiController o direttamente nel model Movimenti
|
||||
|
||||
}
|
||||
|
@ -5,10 +5,13 @@ 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 App\Models\ImportRule;
|
||||
|
||||
|
||||
class Movimenti extends Model
|
||||
{
|
||||
@ -16,10 +19,23 @@ class Movimenti extends Model
|
||||
protected $dates = ['mov_data'];
|
||||
protected $casts = [ 'mov_data'=>'datetime'];
|
||||
|
||||
protected $fillable = [
|
||||
'mov_data',
|
||||
'mov_fk_categoria',
|
||||
'mov_descrizione',
|
||||
'mov_importo_dare',
|
||||
'mov_importo_avere',
|
||||
'mov_inserito_da',
|
||||
'mov_fk_tags',
|
||||
'conto_id_da',
|
||||
'conto_id_a'
|
||||
];
|
||||
|
||||
public static $query= 'SELECT
|
||||
a.id,
|
||||
a.mov_data,
|
||||
a.mov_importo,
|
||||
a.mov_importo_dare,
|
||||
a.mov_importo_avere,
|
||||
a.mov_descrizione,
|
||||
c.cat_name,
|
||||
t.tag_name,
|
||||
@ -45,7 +61,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() {
|
||||
@ -55,7 +71,8 @@ JOIN categories as c ON a.mov_fk_categoria=c.id';
|
||||
'SELECT
|
||||
a.id,
|
||||
a.mov_data,
|
||||
a.mov_importo,
|
||||
a.mov_importo_dare,
|
||||
a.mov_importo_avere,
|
||||
a.mov_descrizione,
|
||||
c.cat_name,
|
||||
t.tag_name,
|
||||
@ -64,7 +81,7 @@ JOIN categories as c ON a.mov_fk_categoria=c.id';
|
||||
FROM movimentis as a
|
||||
JOIN tags as t ON a.mov_fk_tags=t.id
|
||||
JOIN categories as c ON a.mov_fk_categoria=c.id
|
||||
JOIN contos as co ON a.conto_id=co.id'
|
||||
JOIN contos as co ON a.conto_id_da=co.id'
|
||||
);
|
||||
|
||||
$query = $expression->getValue(DB::connection()->getQueryGrammar());
|
||||
@ -171,7 +188,8 @@ JOIN categories as c ON a.mov_fk_categoria=c.id';
|
||||
'mov_data' => $request['mov_data'],
|
||||
'mov_fk_categoria'=>$request['mov_fk_categoria'],
|
||||
'mov_descrizione'=>$request['mov_descrizione'],
|
||||
'mov_importo'=>$request['mov_importo'],
|
||||
'mov_importo_dare' => $request['mov_importo_dare'],
|
||||
'mov_importo_avere' => $request['mov_importo_avere'],
|
||||
'mov_fk_tags'=>$request['mov_fk_tags'],
|
||||
'mov_inserito_da'=>$request['userid'],
|
||||
]);
|
||||
@ -188,7 +206,8 @@ JOIN categories as c ON a.mov_fk_categoria=c.id';
|
||||
$expression= DB::raw('SELECT
|
||||
a.id,
|
||||
a.mov_data,
|
||||
a.mov_importo,
|
||||
a.mov_importo_dare,
|
||||
a.mov_importo_avere,
|
||||
a.mov_descrizione,
|
||||
c.cat_name,
|
||||
t.tag_name,
|
||||
@ -207,7 +226,8 @@ JOIN categories as c ON a.mov_fk_categoria=c.id';
|
||||
|
||||
$expression=DB::raw(' SELECT a.id,
|
||||
a.mov_data,
|
||||
a.mov_importo,
|
||||
a.mov_importo_dare,
|
||||
a.mov_importo_avere,
|
||||
a.mov_descrizione,
|
||||
c.cat_name,
|
||||
t.tag_name,
|
||||
@ -226,7 +246,8 @@ JOIN categories as c ON a.mov_fk_categoria=c.id';
|
||||
$expression=DB::raw('SELECT
|
||||
a.id,
|
||||
a.mov_data,
|
||||
a.mov_importo,
|
||||
a.mov_importo_dare,
|
||||
a.mov_importo_avere,
|
||||
a.mov_descrizione,
|
||||
c.cat_name,
|
||||
t.tag_name,
|
||||
@ -242,7 +263,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 +296,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,46 +338,65 @@ 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;
|
||||
}
|
||||
|
||||
// Test applicazione regole
|
||||
public function setCategoriaMovimento($movimento)
|
||||
public static function getDbFields()
|
||||
{
|
||||
$rules= \App\Models\ImportRule::all();
|
||||
return [
|
||||
"Data movimento"=>"mov_data",
|
||||
"Descrizione"=>"mov_descrizione",
|
||||
"Importo Dare"=>"mov_importo_dare",
|
||||
"Importo Avere"=>"mov_importo_avere",
|
||||
"Categoria"=>"mov_fk_categoria",
|
||||
"Tag"=>"mov_fk_tags",
|
||||
"Conto prelievo"=>"conto_id_da",
|
||||
"Conto versamento"=>"conto_id_a",
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($rules as $role)
|
||||
{
|
||||
if (preg_match("/$role->parola/i","$movimento->descrizione"))
|
||||
{
|
||||
$movimento->catemov_fk_categoria=$role->categoria_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$movimento->catemov_fk_categoria=1;
|
||||
|
||||
|
||||
// Ritorna la categoria suggerita in base alla descrizione del movimento da utilizzare sul db
|
||||
public static function getSuggestedCategory($descrizione)
|
||||
{
|
||||
$rule = ImportRule::whereRaw('? LIKE CONCAT("%", pattern, "%")', [$descrizione])->first();
|
||||
return $rule ? $rule->category_id : 1;
|
||||
}
|
||||
|
||||
public static function setCategoriesFromCsv($descrizione)
|
||||
{
|
||||
$rules = ImportRule::all();
|
||||
$categoria = 1; // Default category
|
||||
|
||||
foreach ($rules as $rule) {
|
||||
if (preg_match("/$rule->pattern/i", $descrizione)) {
|
||||
$categoria = $rule->category_id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $categoria;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Ritorna gli anni presenti nei movimenti
|
||||
public static function getYearsFromMovimenti()
|
||||
{
|
||||
$anni=DB::table('movimentis')->select(DB::raw('DISTINCT YEAR(mov_data) as anno'))->get();
|
||||
// dd($anni); // for test purposes
|
||||
return $anni;
|
||||
return self::selectRaw('YEAR(mov_data) as anno')
|
||||
->distinct()
|
||||
->orderBy('anno', 'desc')
|
||||
->get();
|
||||
}
|
||||
|
||||
|
||||
@ -375,24 +415,27 @@ JOIN categories as c ON a.mov_fk_categoria=c.id';
|
||||
}
|
||||
}
|
||||
|
||||
// Ritorna la somma delle entrate per un anno specifico
|
||||
public static function getEntrate($year)
|
||||
{
|
||||
$entrate_anno=DB::table('movimentis')
|
||||
->where('mov_importo','>',0)
|
||||
->whereYear('mov_data', '=' , $year)
|
||||
->sum('mov_importo');
|
||||
//->get();
|
||||
return $entrate_anno;
|
||||
return self::whereYear('mov_data', $year)
|
||||
->sum('mov_importo_avere');
|
||||
}
|
||||
|
||||
// Ritorna la somma delle uscite per un anno specifico
|
||||
public static function getUscite($year)
|
||||
{
|
||||
$uscite_anno=DB::table('movimentis')
|
||||
->where('mov_importo','<',0)
|
||||
->whereYear('mov_data', '=' , $year)
|
||||
->sum('mov_importo');
|
||||
//->get();
|
||||
return ($uscite_anno);
|
||||
return self::whereYear('mov_data', $year)
|
||||
->sum('mov_importo_dare');
|
||||
}
|
||||
|
||||
public static function cleanImporto($importo){
|
||||
// Rimuove i punti e sostituisce la virgola con un punto
|
||||
$importo = str_replace('.', '', $importo);
|
||||
$importo = str_replace(',', '.', $importo);
|
||||
$importo = str_replace('-', '', $importo);
|
||||
$importo = str_replace('+', '', $importo);
|
||||
return $importo;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -383,6 +383,16 @@ return [
|
||||
'text' => 'Importa Estratto conto Cassa Rurale',
|
||||
'route' => 'importCR',
|
||||
],
|
||||
[
|
||||
'text' => 'Importa Generic CSV',
|
||||
'route' => 'importGen',
|
||||
],
|
||||
[
|
||||
'text' => 'Regole importazione',
|
||||
'route' => 'import_rules.index',
|
||||
// 'can' => ['import_rules'],
|
||||
],
|
||||
|
||||
],
|
||||
],
|
||||
],
|
||||
|
@ -65,6 +65,14 @@ return [
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'app' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/gestionale2025.log'),
|
||||
'level' => env('LOG_LEVEL', 'debug'),
|
||||
'days' => env('LOG_DAILY_DAYS', 14),
|
||||
'replace_placeholders' => true,
|
||||
],
|
||||
|
||||
'daily' => [
|
||||
'driver' => 'daily',
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
|
@ -20,12 +20,14 @@ class CreateMovimentisTable extends Migration
|
||||
$table->unsignedBigInteger('mov_fk_categoria');
|
||||
$table->foreign('mov_fk_categoria')->references('id')->on('categories');
|
||||
$table->longText('mov_descrizione');
|
||||
$table->decimal('mov_importo',8,2);
|
||||
$table->decimal('mov_importo_dare',8,2)->nullable();
|
||||
$table->decimal('mov_importo_avere',8,2)->nullable();
|
||||
$table->unsignedBigInteger('mov_inserito_da');
|
||||
$table->foreign('mov_inserito_da')->references('id')->on('users');
|
||||
$table->unsignedBigInteger('mov_fk_tags');
|
||||
$table->foreign('mov_fk_tags')->references('id')->on('tags');
|
||||
$table->foreignId('conto_id')->constrained('contos');
|
||||
$table->foreignId('conto_id_da')->constrained('contos')->nullable();
|
||||
$table->foreignId('conto_id_a')->constrained('contos')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,13 @@ return new class extends Migration
|
||||
Schema::create('import_rules', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->timestamps();
|
||||
$table->string('pattern');
|
||||
$table->unsignedBigInteger('category_id');
|
||||
$table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');
|
||||
// $table->unique(['pattern', 'category_id'], 'unique_import_rule');
|
||||
$table->string('description')->nullable(); // Optional description for the rule
|
||||
$table->boolean('is_active')->default(true); // Flag to enable/disable the rule
|
||||
$table->string('created_by')->nullable(); // User who created the rule
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -17,9 +17,9 @@ class CategorieSeeder extends Seeder
|
||||
// Inserisce le categorie necessarie
|
||||
DB::table('categories')->insert(
|
||||
[
|
||||
'cat_name'=>'Automobili',
|
||||
'cat_name'=>'Da Selezionare',
|
||||
'cat_uscita'=>1,
|
||||
'cat_entrata'=>0,
|
||||
'cat_entrata'=>1,
|
||||
]
|
||||
);
|
||||
DB::table('categories')->insert(
|
||||
@ -30,9 +30,23 @@ class CategorieSeeder extends Seeder
|
||||
);
|
||||
DB::table('categories')->insert(
|
||||
[
|
||||
'cat_name'=>'Utenze',
|
||||
'cat_name'=>'Automobili',
|
||||
'cat_uscita'=>1,
|
||||
'cat_entrata'=>0]
|
||||
);
|
||||
DB::table('categories')->insert(
|
||||
[
|
||||
'cat_name'=>'Alimentari',
|
||||
'cat_uscita'=>1,
|
||||
'cat_entrata'=>0,
|
||||
]
|
||||
);
|
||||
DB::table('categories')->insert(
|
||||
[
|
||||
'cat_name'=>'Utenze',
|
||||
'cat_uscita'=>1,
|
||||
'cat_entrata'=>0,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -91,6 +91,7 @@ $.getJSON("/admin/service/contolist", {}, function(contis) {
|
||||
});
|
||||
});
|
||||
|
||||
// Modifica movimento
|
||||
$(document).on('click', '.open_modal_modifica', function() {
|
||||
var url = "/admin/movimenti/modify";
|
||||
var riga_id = $(this).val();
|
||||
@ -135,9 +136,9 @@ $(document).on('click', '.open_modal_modifica', function() {
|
||||
);
|
||||
});
|
||||
$('.modal-title').text('Modifica movimento');
|
||||
$('#data').val(data[0].mov_data);
|
||||
$('#data').val(data[0].mov_data.substring(0,10));
|
||||
$('#descrizione').val(data[0].mov_descrizione);
|
||||
$('#importo').val(data[0].mov_importo);
|
||||
$('#importo').val(data[0].mov_importo_dare);
|
||||
|
||||
$('#myModal').modal('show');
|
||||
// $('.panel-heading').text('Modifica movimento');
|
||||
|
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
|
29
resources/views/conti/importGeneric.blade.php
Normal file
29
resources/views/conti/importGeneric.blade.php
Normal file
@ -0,0 +1,29 @@
|
||||
@extends('adminlte::page')
|
||||
|
||||
@section('content_header')
|
||||
<h3> Mappa i campi </h3>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<form action="{{ route('conti.map.store') }}" method="POST">
|
||||
@csrf
|
||||
@foreach ($db as $header=>$table)
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<label>{{ $header }}</label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<select name="mapping[{{ $table }}]">
|
||||
<option value="">--Nessuno o Selezionare una colonna--</option>
|
||||
@foreach($csv as $csv_header)
|
||||
<option value="{{ $csv_header }}">{{ $csv_header }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@endforeach
|
||||
<input type="hidden" name="filename" value="{{ $filename .".csv" }}">
|
||||
<button type="submit">Salva</button>
|
||||
</form>
|
||||
@endsection
|
@ -32,21 +32,24 @@
|
||||
<tr>
|
||||
<th>Data</th>
|
||||
<th>Categoria</th>
|
||||
<th>Conto</th>
|
||||
<th>Conto Dare</th>
|
||||
<th>Conto Avere</th>
|
||||
<th>Descrizione</th>
|
||||
<th>Importo</th>
|
||||
<th>Importo Dare</th>
|
||||
<th>Importo Avere</th>
|
||||
<th>Azione</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach( $movimenti as $movimento )
|
||||
<tr>
|
||||
|
||||
<td>{{ $movimento->mov_data}}</td>
|
||||
<td>{{ $movimento->cat_name }}</td>
|
||||
<td>{{ $movimento->nomeConto }}</td>
|
||||
<td>{{ $movimento->nomeContoDare ?? '' }}</td>
|
||||
<td>{{ $movimento->nomeContoAvere ?? '' }}</td>
|
||||
<td>{{ $movimento->mov_descrizione }}</td>
|
||||
<td>€ {{ $movimento->mov_importo }}</td>
|
||||
<td>{{ $movimento->mov_importo_dare ." €"}}</td>
|
||||
<td>{{ $movimento->mov_importo_avere." €" }}</td>
|
||||
<td>
|
||||
<button class="btn btn-warning btn-detail open_modal_modifica" value="{{ $movimento->id }}"><i class="fa-solid fa-pencil"></i></button>
|
||||
<a class="btn btn-danger" href="/admin/movimenti/delete?id={{ $movimento->id }}"><i class="fa-solid fa-trash-can"></i></a>
|
||||
@ -69,6 +72,8 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- MODAL NEW -->
|
||||
<div class="modal fade " id="myModal" tabindex="-1" role="dialog"
|
||||
aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
@ -108,10 +113,10 @@
|
||||
<div class="col-xs-5">
|
||||
<label for="importo" class="form-label">Importo</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"> <i class="fa fa-eur"></i>
|
||||
</span> <input type="number" step="0.01" min="-999999"
|
||||
<span class="input-group-addon"> <i class="fa fa-eur"></i></span>
|
||||
<input type="number" step="0.01" min="-999999"
|
||||
max="999999" class="form-control" id="importo" size="50"
|
||||
name="mov_importo" aria-describedby="importo">
|
||||
name="mov_importo_dare" aria-describedby="importo">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-7">
|
||||
|
46
resources/views/import_rules/create.blade.php
Normal file
46
resources/views/import_rules/create.blade.php
Normal file
@ -0,0 +1,46 @@
|
||||
@extends('adminlte::page')
|
||||
|
||||
@section('content_header')
|
||||
<h1>Crea una regola di importazione</h1>
|
||||
@stop
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<p>Compila il modulo per creare una nuova regola di importazione.</p>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Nuova Regola di Importazione</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="{{ route('import_rules.store') }}" method="POST">
|
||||
@csrf
|
||||
<div class="form-group">
|
||||
<label for="pattern">Pattern</label>
|
||||
<input type="text" name="pattern" id="pattern" class="form-control" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="category_id">Categoria</label>
|
||||
<select name="category_id" id="category_id" class="form-control" required>
|
||||
<option value="">Seleziona una categoria</option>
|
||||
@foreach($categorie as $category)
|
||||
<option value="{{ $category->id }}">{{ $category->cat_name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<div class="form-group">
|
||||
<label for="description">Descrizione</label>
|
||||
<textarea name="description" id="description" class="form-control" rows="3" required></textarea>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<button type="submit" class="btn btn-primary">Crea Regola</button>
|
||||
<a href="{{ route('import_rules.index') }}" class="btn btn-secondary">Annulla</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="card-footer">
|
||||
<a href="{{ route('import_rules.index') }}" class="btn btn-secondary">Torna alla lista</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
49
resources/views/import_rules/index.blade.php
Normal file
49
resources/views/import_rules/index.blade.php
Normal file
@ -0,0 +1,49 @@
|
||||
@extends('adminlte::page')
|
||||
|
||||
@section('content_header')
|
||||
<h1>Regole di importazione e assegnazione delle categorie</h1>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="container">
|
||||
<p>Qui puoi gestire le regole di importazione e assegnazione delle categorie.</p>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Regole di Importazione</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<table class="table table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Pattern</th>
|
||||
<th>Descrizione</th>
|
||||
<th>Azioni</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($rules as $rule)
|
||||
<tr>
|
||||
<td>{{ $rule->id }}</td>
|
||||
<td>{{ $rule->pattern }}</td>
|
||||
<td>{{ $rule->description }}</td>
|
||||
<td>
|
||||
<a href="{{ route('import_rules.edit', $rule->id) }}" class="btn btn-primary btn-sm">Modifica</a>
|
||||
<form action="{{ route('import_rules.destroy', $rule->id) }}" method="POST" style="display:inline;">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button type="submit" class="btn btn-danger btn-sm">Elimina</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<a href="{{ route('import_rules.create') }}" class="btn btn-success">Aggiungi Nuova Regola</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
@ -26,6 +26,7 @@ use App\Http\Controllers\ContrattiController;
|
||||
use App\Http\Controllers\TodolistController;
|
||||
use App\Http\Controllers\ContoController;
|
||||
use App\Http\Controllers\GenDocController;
|
||||
use App\Http\Controllers\ImportRuleController;
|
||||
use App\Mail\myTestEmail;
|
||||
|
||||
// API
|
||||
@ -94,12 +95,26 @@ 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/giroconto', [MovimentiController::class,'giroconto'])->name('giroconto');
|
||||
Route::post('/admin/movimenti/giroconto', [MovimentiController::class,'girocontoPost']);
|
||||
Route::get('admin/movimenti/importgen', [MovimentiController::class,'importFileGen'])->name('importGen');
|
||||
Route::post('admin/movimenti/importgen', [MovimentiController::class,'importGenericCsv']);
|
||||
Route::post('admin/movimenti/importmapped', [MovimentiController::class,'importmappedCsv'])->name('conti.map.store');
|
||||
|
||||
|
||||
Route::get('/admin/movimenti/import_rules', [ImportRuleController::class, 'index'])->name('import_rules.index');
|
||||
Route::get('/admin/movimenti/import_rules/create', [ImportRuleController::class, 'create'])->name('import_rules.create');
|
||||
Route::post('/admin/movimenti/import_rules', [ImportRuleController::class, 'store'])->name('import_rules.store');
|
||||
Route::get('/admin/movimenti/import_rules/{import_rule}', [ImportRuleController::class, 'show'])->name('import_rules.show');
|
||||
Route::get('/admin/movimenti/import_rules/{import_rule}/edit', [ImportRuleController::class, 'edit'])->name('import_rules.edit');
|
||||
Route::put('/admin/movimenti/import_rules/{import_rule}', [ImportRuleController::class, 'update'])->name('import_rules.update');
|
||||
Route::delete('/admin/movimenti/import_rules/{import_rule}', [ImportRuleController::class, 'destroy'])->name('import_rules.destroy');
|
||||
|
||||
|
||||
Route::resource('admin/conti', ContoController::class);
|
||||
|
||||
|
||||
Route::get('/admin/movimenti/giroconto', [MovimentiController::class,'giroconto'])->name('giroconto');
|
||||
Route::post('/admin/movimenti/giroconto', [MovimentiController::class,'girocontoPost']);
|
||||
|
||||
// CATEGORIE
|
||||
Route::get('admin/categorie', [CategorieController::class,'listCategorie'])->name('categorie');
|
||||
Route::post('admin/categorie', [CategorieController::class,'insCategorie']);
|
||||
@ -262,5 +277,6 @@ Route::middleware('auth:sanctum')->group(function () {
|
||||
Route::delete('/api/conti/{id}', [ApiContoController::class, 'deleteConto']);
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user