Compare commits
No commits in common. "bc769008b39cdc65196afe610b91f7036333a277" and "097b7e922dcaad1fffb29650efc614281f4efa94" have entirely different histories.
bc769008b3
...
097b7e922d
@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Categorie;
|
||||
use App\Models\ImportRule;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@ -14,8 +13,6 @@ class ImportRuleController extends Controller
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
$rules = ImportRule::all();
|
||||
return view('import_rules.index', compact('rules'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -24,11 +21,6 @@ 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);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -37,23 +29,6 @@ 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,14 +13,9 @@ 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
|
||||
@ -34,15 +29,13 @@ class MovimentiController extends Controller
|
||||
public static function listMovimenti(){
|
||||
$categorie=Categorie::list();
|
||||
$tags=tag::getList();
|
||||
$contos=Conto::all();
|
||||
/* Query per visualizzare anche il totale dei documenti presenti per il record */
|
||||
$movimenti=Movimenti::getList();
|
||||
|
||||
//dd($movimenti);
|
||||
|
||||
return view('conti.movimenti.list',[
|
||||
'categorie'=>$categorie,
|
||||
'movimenti'=>$movimenti,
|
||||
'contos'=>$contos,
|
||||
'tags'=>$tags
|
||||
]);
|
||||
}
|
||||
@ -229,32 +222,14 @@ class MovimentiController extends Controller
|
||||
$ncategoria=$categoria->cat_name;
|
||||
for ($i=1;$i<=12;$i++)
|
||||
{
|
||||
$importo_dare = DB::table('movimentis')
|
||||
->whereMonth('mov_data', '=', $i)
|
||||
->whereYear('mov_data', '=', $anno)
|
||||
->where('mov_fk_categoria', '=', $id)
|
||||
->sum('mov_importo_dare');
|
||||
|
||||
$importo_avere = DB::table('movimentis')
|
||||
->whereMonth('mov_data', '=', $i)
|
||||
->whereYear('mov_data', '=', $anno)
|
||||
->where('mov_fk_categoria', '=', $id)
|
||||
->sum('mov_importo_avere');
|
||||
|
||||
// $movrow=DB::table('movimentis')
|
||||
// ->whereMonth('mov_data','=',$i)
|
||||
// ->whereYear('mov_data','=',$anno)
|
||||
// ->where('mov_fk_categoria','=',$id)
|
||||
// ->sum('mov_importo_dare')
|
||||
// ->sum('mov_importo_avere');
|
||||
$movrow = $importo_avere - $importo_dare;
|
||||
|
||||
$movrow=DB::table('movimentis')
|
||||
->whereMonth('mov_data','=',$i)
|
||||
->whereYear('mov_data','=',$anno)
|
||||
->where('mov_fk_categoria','=',$id)
|
||||
->sum('mov_importo');
|
||||
$coll[]=$movrow;
|
||||
$collx[]=$movrow;
|
||||
}
|
||||
//TEST
|
||||
// dd($movrow);
|
||||
// /TEST
|
||||
$totale[]=array_sum($collx);
|
||||
unset($collx);
|
||||
}
|
||||
@ -360,84 +335,6 @@ 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::importNoDuplicate($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');
|
||||
@ -448,13 +345,6 @@ class MovimentiController extends Controller
|
||||
return view('conti.importCR');
|
||||
}
|
||||
|
||||
public function importFileGen()
|
||||
{
|
||||
return view('conti.importGen');
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* public function test()
|
||||
{
|
||||
Movimenti::getYearsFromMovimenti();
|
||||
@ -470,5 +360,4 @@ class MovimentiController extends Controller
|
||||
$mov=Movimenti::getMovimentoById($id);
|
||||
return json_encode($mov);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,14 +8,4 @@ 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,13 +5,10 @@ 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
|
||||
{
|
||||
@ -19,24 +16,10 @@ 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',
|
||||
'import_hash',
|
||||
];
|
||||
|
||||
public static $query= 'SELECT
|
||||
a.id,
|
||||
a.mov_data,
|
||||
a.mov_importo_dare,
|
||||
a.mov_importo_avere,
|
||||
a.mov_importo,
|
||||
a.mov_descrizione,
|
||||
c.cat_name,
|
||||
t.tag_name,
|
||||
@ -45,15 +28,10 @@ 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';
|
||||
|
||||
public function ContoDa()
|
||||
{
|
||||
return $this->belongsTo(Conto::class, 'conto_id_da');
|
||||
}
|
||||
|
||||
public function ContoA()
|
||||
{
|
||||
return $this->belongsTo(Conto::class, 'conto_id_a');
|
||||
}
|
||||
public function Conto()
|
||||
{
|
||||
return $this->belongsTo(Conto::class);
|
||||
}
|
||||
|
||||
public function User()
|
||||
{
|
||||
@ -62,20 +40,35 @@ public function ContoA()
|
||||
|
||||
public function Categorie()
|
||||
{
|
||||
return $this->belongsTo(Categorie::class, 'mov_fk_categoria');
|
||||
return $this->belongsTo(Categorie::class);
|
||||
}
|
||||
|
||||
public function Tags()
|
||||
{
|
||||
return $this->belongsTo(tag::class);
|
||||
return $this->belongsTo(Tags::class);
|
||||
}
|
||||
|
||||
public static function getList() {
|
||||
|
||||
// ISSUE #3 - Aggiunta visualizzazione conto da e conto a nella lista dei movimenti
|
||||
// e risoluzione duplicazione movimenti.
|
||||
|
||||
return self::with(['Tags', 'Categorie', 'ContoDa', 'ContoA'])->orderBy('mov_data','desc')->get();
|
||||
$expression=DB::raw(
|
||||
'SELECT
|
||||
a.id,
|
||||
a.mov_data,
|
||||
a.mov_importo,
|
||||
a.mov_descrizione,
|
||||
c.cat_name,
|
||||
t.tag_name,
|
||||
co.nomeConto,
|
||||
(SELECT Count(entity_id) as quanti FROM gen_docs WHERE entity=0 AND entity_id = a.id) as quanti
|
||||
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'
|
||||
);
|
||||
|
||||
$query = $expression->getValue(DB::connection()->getQueryGrammar());
|
||||
return DB::select($query);
|
||||
}
|
||||
|
||||
public static function getSaldo($date) {
|
||||
@ -96,9 +89,6 @@ public function ContoA()
|
||||
'mov_fk_tags'=>$request->mov_fk_tags,
|
||||
'mov_inserito_da'=>$request->userid,
|
||||
'conto_id'=>$request->conto_id,
|
||||
|
||||
// 'conto_id_da'=>$request->conto_id_da,
|
||||
// 'conto_id_a'=>$request->conto_id_a,
|
||||
]);
|
||||
}
|
||||
|
||||
@ -175,17 +165,16 @@ public function ContoA()
|
||||
}
|
||||
|
||||
public static function updateMovimenti($request) {
|
||||
$updateData = [];
|
||||
if (isset($request['mov_data'])) $updateData['mov_data'] = $request['mov_data'];
|
||||
if (isset($request['mov_fk_categoria'])) $updateData['mov_fk_categoria'] = $request['mov_fk_categoria'];
|
||||
if (isset($request['mov_descrizione'])) $updateData['mov_descrizione'] = $request['mov_descrizione'];
|
||||
if (isset($request['mov_importo_dare'])) $updateData['mov_importo_dare'] = $request['mov_importo_dare'];
|
||||
if (isset($request['mov_importo_avere'])) $updateData['mov_importo_avere'] = $request['mov_importo_avere'];
|
||||
if (isset($request['mov_fk_tags'])) $updateData['mov_fk_tags'] = $request['mov_fk_tags'];
|
||||
if (isset($request['userid'])) $updateData['mov_inserito_da'] = $request['userid'];
|
||||
|
||||
self::where('id', $request['id'])->update($updateData);
|
||||
|
||||
DB::table('movimentis')
|
||||
->where('id','=', $request['id'])
|
||||
->update([
|
||||
'mov_data' => $request['mov_data'],
|
||||
'mov_fk_categoria'=>$request['mov_fk_categoria'],
|
||||
'mov_descrizione'=>$request['mov_descrizione'],
|
||||
'mov_importo'=>$request['mov_importo'],
|
||||
'mov_fk_tags'=>$request['mov_fk_tags'],
|
||||
'mov_inserito_da'=>$request['userid'],
|
||||
]);
|
||||
}
|
||||
|
||||
public static function deleteMovimento($id) {
|
||||
@ -196,90 +185,48 @@ public function ContoA()
|
||||
|
||||
public static function listByCatMonth($month,$cat,$year) {
|
||||
|
||||
// $expression= DB::raw('SELECT
|
||||
// a.id,
|
||||
// a.mov_data,
|
||||
// a.mov_importo_dare,
|
||||
// a.mov_importo_avere,
|
||||
// a.mov_descrizione,
|
||||
// c.cat_name,
|
||||
// t.tag_name,
|
||||
// (SELECT Count(entity_id) as quanti FROM gen_docs WHERE entity=0 AND entity_id = a.id) as quanti
|
||||
// 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
|
||||
// WHERE Month(a.mov_data)='.$month.' AND Year(a.mov_data)='.$year.' AND a.mov_fk_categoria='.$cat
|
||||
// );
|
||||
// $query = $expression->getValue(DB::connection()->getQueryGrammar());
|
||||
// return DB::select($query);
|
||||
return self::with(['Tags', 'Categorie'])
|
||||
->whereMonth('mov_data', $month)
|
||||
->whereYear('mov_data', $year)
|
||||
->where('mov_fk_categoria', $cat)
|
||||
->get();
|
||||
$expression= DB::raw('SELECT
|
||||
a.id,
|
||||
a.mov_data,
|
||||
a.mov_importo,
|
||||
a.mov_descrizione,
|
||||
c.cat_name,
|
||||
t.tag_name,
|
||||
(SELECT Count(entity_id) as quanti FROM gen_docs WHERE entity=0 AND entity_id = a.id) as quanti
|
||||
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
|
||||
WHERE Month(a.mov_data)='.$month.' AND Year(a.mov_data)='.$year.' AND a.mov_fk_categoria='.$cat
|
||||
);
|
||||
$query = $expression->getValue(DB::connection()->getQueryGrammar());
|
||||
return DB::select($query);
|
||||
|
||||
}
|
||||
|
||||
public static function listByCategory($cat) {
|
||||
|
||||
// $expression=DB::raw(' SELECT a.id,
|
||||
// a.mov_data,
|
||||
// a.mov_importo_dare,
|
||||
// a.mov_importo_avere,
|
||||
// a.mov_descrizione,
|
||||
// c.cat_name,
|
||||
// t.tag_name,
|
||||
// (SELECT Count(entity_id) as quanti FROM gen_docs WHERE entity=0 AND entity_id = a.id) as quanti
|
||||
// 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
|
||||
// WHERE a.mov_fk_categoria = '.$cat );
|
||||
$expression=DB::raw(' SELECT a.id,
|
||||
a.mov_data,
|
||||
a.mov_importo,
|
||||
a.mov_descrizione,
|
||||
c.cat_name,
|
||||
t.tag_name,
|
||||
(SELECT Count(entity_id) as quanti FROM gen_docs WHERE entity=0 AND entity_id = a.id) as quanti
|
||||
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
|
||||
WHERE a.mov_fk_categoria = '.$cat );
|
||||
|
||||
// $query = $expression->getValue(DB::connection()->getQueryGrammar());
|
||||
// return DB::select($query);
|
||||
return self::with(['Tags', 'Categorie'])
|
||||
->where('mov_fk_categoria', $cat)
|
||||
->get();
|
||||
$query = $expression->getValue(DB::connection()->getQueryGrammar());
|
||||
return DB::select($query);
|
||||
|
||||
}
|
||||
|
||||
public static function makeHash($data,$movimento_dare, $movimento_avere, $descrizione)
|
||||
{
|
||||
// crea l'hash (serve per evitare duplicati nei movimenti)
|
||||
return md5($data.$movimento_dare.$movimento_avere.$descrizione);
|
||||
}
|
||||
|
||||
public static function importHashExists($hash)
|
||||
{
|
||||
return self::where('import_hash', $hash)->exists();
|
||||
}
|
||||
|
||||
public static function importNoDuplicate($data)
|
||||
{
|
||||
$hash = Movimenti::makeHash($data['mov_data'], $data['mov_importo_dare'], $data['mov_importo_avere'], $data['mov_descrizione']);
|
||||
$exists = self::where('import_hash', $hash)->exists();
|
||||
if (!$exists) {
|
||||
self::create([
|
||||
// TODO: ...altri campi...
|
||||
'mov_data' => $data['mov_data'],
|
||||
'mov_fk_categoria' => $data['mov_fk_categoria'],
|
||||
'mov_descrizione' => $data['mov_descrizione'],
|
||||
'mov_importo_dare' => $data['mov_importo_dare'],
|
||||
'mov_importo_avere' => $data['mov_importo_avere'],
|
||||
'mov_inserito_da' => 1,
|
||||
'conto_id_da' => 1,
|
||||
'conto_id_a' => 1,
|
||||
'mov_fk_tags' => 1,
|
||||
'import_hash' => $hash,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getByTag($tag) {
|
||||
$expression=DB::raw('SELECT
|
||||
a.id,
|
||||
a.mov_data,
|
||||
a.mov_importo_dare,
|
||||
a.mov_importo_avere,
|
||||
a.mov_importo,
|
||||
a.mov_descrizione,
|
||||
c.cat_name,
|
||||
t.tag_name,
|
||||
@ -295,7 +242,7 @@ public function ContoA()
|
||||
public static function importEstrattoIng($filename)
|
||||
{
|
||||
|
||||
$inputPath='/var/www/html/gestionale2025/storage/app/public/'.$filename;
|
||||
$inputPath='/var/www/html/gestionale_mt/public/storage/tenant'.tenant('id').'/'.$filename;
|
||||
// $outputPath='/var/www/html/gestionale_mt/public/tenant'.tenant('id').'/import/'.$filename.'.csv';
|
||||
$outputPath = $inputPath.'.csv';
|
||||
rename($inputPath,$outputPath);
|
||||
@ -328,7 +275,7 @@ public function ContoA()
|
||||
|
||||
public static function importEstrattoCR($filename)
|
||||
{
|
||||
$inputPath='/var/www/html/gestionale2025/storage/app/public/'.$filename;
|
||||
$inputPath='/var/www/html/gestionale_mt/public/storage/tenant'.tenant('id').'/'.$filename;
|
||||
// $outputPath='/var/www/html/gestionale_mt/public/'.tenant('id')."/app/".$filename;
|
||||
$outputPath = $inputPath.'.csv';
|
||||
rename($inputPath,$outputPath);
|
||||
@ -370,72 +317,46 @@ public function ContoA()
|
||||
}
|
||||
|
||||
// Test filtri categoria
|
||||
public static function retrieveHeaders($filename)
|
||||
public function mapFieldByName($name)
|
||||
{
|
||||
$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()
|
||||
// definisce lo schema per rigenerare il file CSV secondo standard di importazione
|
||||
$fields = Illuminate\Support\Facade\Schema::getColumnListing('movimentis')->mapFieldByName;
|
||||
foreach ($fields as $field)
|
||||
{
|
||||
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",
|
||||
];
|
||||
echo $column . "\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Ritorna la categoria suggerita in base alla descrizione del movimento da utilizzare sul db
|
||||
public static function getSuggestedCategory($descrizione)
|
||||
// Test applicazione regole
|
||||
public function setCategoriaMovimento($movimento)
|
||||
{
|
||||
$rule = ImportRule::whereRaw('? LIKE CONCAT("%", pattern, "%")', [$descrizione])->first();
|
||||
return $rule ? $rule->category_id : 1;
|
||||
}
|
||||
$rules= \App\Models\ImportRule::all();
|
||||
|
||||
public static function setCategoriesFromCsv($descrizione)
|
||||
foreach ($rules as $role)
|
||||
{
|
||||
$rules = ImportRule::all();
|
||||
$categoria = 1; // Default category
|
||||
|
||||
foreach ($rules as $rule) {
|
||||
if (preg_match("/$rule->pattern/i", $descrizione)) {
|
||||
$categoria = $rule->category_id;
|
||||
break;
|
||||
if (preg_match("/$role->parola/i","$movimento->descrizione"))
|
||||
{
|
||||
$movimento->catemov_fk_categoria=$role->categoria_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$movimento->catemov_fk_categoria=1;
|
||||
}
|
||||
}
|
||||
|
||||
return $categoria;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Ritorna gli anni presenti nei movimenti
|
||||
|
||||
|
||||
public static function getYearsFromMovimenti()
|
||||
{
|
||||
if (env('DB_CONNECTION')=='mysql') {
|
||||
return self::selectRaw('DISTINCT YEAR(mov_data) as anno')
|
||||
->orderBy('anno', 'desc')
|
||||
->get();
|
||||
} else
|
||||
{
|
||||
return self::selectRaw("strftime('%Y', mov_data) as anno")
|
||||
->distinct()
|
||||
->orderBy('anno', 'desc')
|
||||
->get();
|
||||
}
|
||||
$anni=DB::table('movimentis')->select(DB::raw('DISTINCT YEAR(mov_data) as anno'))->get();
|
||||
// dd($anni); // for test purposes
|
||||
return $anni;
|
||||
}
|
||||
|
||||
|
||||
@ -454,27 +375,24 @@ public function ContoA()
|
||||
}
|
||||
}
|
||||
|
||||
// Ritorna la somma delle entrate per un anno specifico
|
||||
public static function getEntrate($year)
|
||||
{
|
||||
return self::whereYear('mov_data', $year)
|
||||
->sum('mov_importo_avere');
|
||||
$entrate_anno=DB::table('movimentis')
|
||||
->where('mov_importo','>',0)
|
||||
->whereYear('mov_data', '=' , $year)
|
||||
->sum('mov_importo');
|
||||
//->get();
|
||||
return $entrate_anno;
|
||||
}
|
||||
|
||||
// Ritorna la somma delle uscite per un anno specifico
|
||||
public static function getUscite($year)
|
||||
{
|
||||
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;
|
||||
$uscite_anno=DB::table('movimentis')
|
||||
->where('mov_importo','<',0)
|
||||
->whereYear('mov_data', '=' , $year)
|
||||
->sum('mov_importo');
|
||||
//->get();
|
||||
return ($uscite_anno);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -383,16 +383,6 @@ 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,14 +65,6 @@ 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,15 +20,12 @@ 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_dare',8,2)->nullable();
|
||||
$table->decimal('mov_importo_avere',8,2)->nullable();
|
||||
$table->decimal('mov_importo',8,2);
|
||||
$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_da')->constrained('contos')->nullable();
|
||||
$table->foreignId('conto_id_a')->constrained('contos')->nullable();
|
||||
$table->string('import_hash')->nullable()->index();
|
||||
$table->foreignId('conto_id')->constrained('contos');
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -14,13 +14,6 @@ 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'=>'Da Selezionare',
|
||||
'cat_name'=>'Automobili',
|
||||
'cat_uscita'=>1,
|
||||
'cat_entrata'=>1,
|
||||
'cat_entrata'=>0,
|
||||
]
|
||||
);
|
||||
DB::table('categories')->insert(
|
||||
@ -30,23 +30,9 @@ class CategorieSeeder extends Seeder
|
||||
);
|
||||
DB::table('categories')->insert(
|
||||
[
|
||||
'cat_name'=>'Automobili',
|
||||
'cat_name'=>'Utenze',
|
||||
'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,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,31 +0,0 @@
|
||||
$(document).ready(function() {
|
||||
$('#category_id').change(function() {
|
||||
if ($(this).val() === 'nuovo') {
|
||||
$('#nuovo_valore').show();
|
||||
$('#nuovo_aggiungi').show();
|
||||
} else {
|
||||
$('#nuovo_valore').hide();
|
||||
$('#nuovo_aggiungi').hide();
|
||||
}
|
||||
});
|
||||
|
||||
$('#nuovo_aggiungi').click(function() {
|
||||
var selectedValue = $('#category_id').val();
|
||||
var nuovoValore = $('#nuovo_valore').val().trim();
|
||||
|
||||
if (selectedValue === 'nuovo' && nuovoValore !== '') {
|
||||
$.post('/api/categorie', { cat_name: nuovoValore,cat_entrata: 1,cat_uscita: 1, _token: $('meta[name="csrf-token"]').attr('content') }, function(data) {
|
||||
if (data.success) {
|
||||
// Aggiungi la nuova categoria alla select e selezionala
|
||||
$('#category_id').append(new Option(nuovoValore, data.id, true, true)).trigger('change');
|
||||
$('#nuovo_valore').val('').hide();
|
||||
$('#nuovo_aggiungi').hide();
|
||||
} else {
|
||||
alert('Errore durante l\'aggiunta della categoria: ' + data.message);
|
||||
}
|
||||
}, 'json');
|
||||
} else {
|
||||
alert('Per favore, inserisci un nome valido per la nuova categoria.');
|
||||
}
|
||||
});
|
||||
});
|
@ -1,87 +1,161 @@
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#listamovimenti').DataTable({
|
||||
responsive: true,
|
||||
columnDefs: [{
|
||||
"responsive": true,
|
||||
columnDefs: [
|
||||
{
|
||||
target: 0,
|
||||
render: DataTable.render.date(),
|
||||
}],
|
||||
order: [[0, "desc"]]
|
||||
}
|
||||
],
|
||||
"order": [[0, "desc"]]
|
||||
});
|
||||
|
||||
// $('.select2').select2();
|
||||
});
|
||||
|
||||
|
||||
$(".draggable").draggable();
|
||||
|
||||
var d = new Date();
|
||||
var month = d.getMonth() + 1;
|
||||
var month = d.getMonth()+1;
|
||||
var day = d.getDate();
|
||||
var strDate = d.getFullYear() + '-' + (month < 10 ? '0' : '') + month + '-' + (day < 10 ? '0' : '') + day;
|
||||
|
||||
function fillSelect(url, selectName, selectedValue) {
|
||||
$(selectName).empty();
|
||||
$.getJSON(url, {}, function(items) {
|
||||
$.each(items, function(i, item) {
|
||||
var label = item.cat_name || item.tag_name || item.nomeConto;
|
||||
$(selectName).append(new Option(label, item.id));
|
||||
});
|
||||
if (selectedValue) {
|
||||
$(selectName).val(selectedValue).trigger('change');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function resetForm(formSelector, dateValue) {
|
||||
$(formSelector).find('input[type="text"], textarea, input[type="number"], input[type="date"], option').val('');
|
||||
$(formSelector).find('input[type="date"]').val(dateValue);
|
||||
}
|
||||
|
||||
function openModal(tipo, actionUrl, catUrl, tagUrl, contoUrl, modalTitle) {
|
||||
resetForm('#form', strDate);
|
||||
$('#myModal').modal('show');
|
||||
$('.modal-title').text(modalTitle);
|
||||
$('#form').attr('action', actionUrl);
|
||||
fillSelect(catUrl, "select[name='mov_fk_categoria']");
|
||||
fillSelect(tagUrl, "select[name='mov_fk_tags']");
|
||||
fillSelect(contoUrl, "select[name='conto_id']");
|
||||
}
|
||||
var strDate = d.getFullYear() + '-' +
|
||||
(month<10 ? '0' : '') + month + '-' +
|
||||
(day<10 ? '0' : '') + day;
|
||||
|
||||
|
||||
$(document).on('click', '.open_modal_spesa', function() {
|
||||
openModal('spesa', '/admin/movimenti/spesa', '/admin/service/catlistSpesa', '/admin/service/taglist', '/admin/service/contolist', 'Nuovo movimento in uscita');
|
||||
$('#importo').attr('name', 'mov_importo_dare');
|
||||
});
|
||||
|
||||
$(document).on('click', '.open_modal_entrata', function() {
|
||||
openModal('entrata', '/admin/movimenti/entrata', '/admin/service/catlistEntrata', '/admin/service/taglist', '/admin/service/contolist', 'Nuovo movimento in entrata');
|
||||
$('#importo').attr('name', 'mov_importo_avere');
|
||||
});
|
||||
|
||||
|
||||
$(document).on('click', '.open_modal_modifica', function() {
|
||||
var riga_id = $(this).val();
|
||||
$.getJSON('/admin/movimenti/modify/' + riga_id, function(data) {
|
||||
resetForm('#form', data[0].mov_data.substring(0, 10));
|
||||
fillSelect('/admin/service/catlist', "select[name='mov_fk_categoria']", data[0].cat_name);
|
||||
fillSelect('/admin/service/taglist', "select[name='mov_fk_tags']", data[0].tag_name);
|
||||
fillSelect('/admin/service/contolist', "select[name='conto_id']", data[0].nomeConto);
|
||||
$('#descrizione').val(data[0].mov_descrizione);
|
||||
|
||||
// Imposta importo e name in base a DARE/AVERE
|
||||
if (data[0].mov_importo_dare && parseFloat(data[0].mov_importo_dare) !== 0) {
|
||||
$('#importo').val(data[0].mov_importo_dare);
|
||||
$('#importo').attr('name', 'mov_importo_dare');
|
||||
} else if (data[0].mov_importo_avere && parseFloat(data[0].mov_importo_avere) !== 0) {
|
||||
$('#importo').val(data[0].mov_importo_avere);
|
||||
$('#importo').attr('name', 'mov_importo_avere');
|
||||
} else {
|
||||
$('#importo').val('');
|
||||
$('#importo').attr('name', 'mov_importo');
|
||||
}
|
||||
|
||||
$('.modal-title').text('Modifica movimento');
|
||||
$('#form').attr('action', '/admin/movimenti/modify');
|
||||
$('#form').append('<input type="hidden" name="id" value="' + riga_id + '">');
|
||||
console.log(strDate);
|
||||
$("#categoria").empty();
|
||||
$("#tags").empty();
|
||||
$('#form').find('input[type="text"], textarea, input[type="number"],input[type="date"],option').val("");
|
||||
$('#form').find('input[type="date"]').val(strDate);
|
||||
$('#myModal').modal('show');
|
||||
$('.modal-title').text(' Nuovo movimento in uscita');
|
||||
$('#form').attr('action', '/admin/movimenti/spesa');
|
||||
$.getJSON("/admin/service/catlistSpesa", {}, function(cats) {
|
||||
$.each(cats, function(i, cat) {
|
||||
$("select[name='mov_fk_categoria']").append(
|
||||
new Option(cat.cat_name, cat.id)
|
||||
)
|
||||
}
|
||||
);
|
||||
});
|
||||
$.getJSON("/admin/service/taglist", {}, function(tags) {
|
||||
$.each(tags, function(i, tag) {
|
||||
$("select[name='mov_fk_tags']").append(
|
||||
new Option(tag.tag_name, tag.id)
|
||||
)
|
||||
});
|
||||
});
|
||||
$.getJSON("/admin/service/contolist", {}, function(contis) {
|
||||
$.each(contis, function(i, conto) {
|
||||
$("select[name='conto_id']").append(
|
||||
new Option(conto.nomeConto, conto.id)
|
||||
)
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
$(document).on('click', '.open_modal_entrata', function() {
|
||||
console.log(strDate);
|
||||
$("#categoria").empty();
|
||||
$("#tags").empty();
|
||||
$('#form').find('input[type="text"], textarea, input[type="number"],option').val("");
|
||||
$('#form').find('input[type="date"]').val(strDate);
|
||||
$('#myModal').modal('show');
|
||||
$('.modal-title').text('Nuovo movimento in entrata');
|
||||
$('#form').attr('action', '/admin/movimenti/entrata');
|
||||
$.getJSON("/admin/service/catlistEntrata", {}, function(data) {
|
||||
$.each(data, function(i, item) {
|
||||
$("select[name='mov_fk_categoria']").append(
|
||||
new Option(item.cat_name, item.id)
|
||||
)
|
||||
}
|
||||
);
|
||||
});
|
||||
$.getJSON("/admin/service/taglist", {}, function(data) {
|
||||
$.each(data, function(i, item) {
|
||||
$("select[name='mov_fk_tags']").append(
|
||||
new Option(item.tag_name, item.id)
|
||||
)
|
||||
});
|
||||
});
|
||||
$.getJSON("/admin/service/contolist", {}, function(contis) {
|
||||
$.each(contis, function(i, conto) {
|
||||
$("select[name='conto_id']").append(
|
||||
new Option(conto.nomeConto, conto.id)
|
||||
)
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on('click', '.open_modal_modifica', function() {
|
||||
var url = "/admin/movimenti/modify";
|
||||
var riga_id = $(this).val();
|
||||
$("#categoria").empty();
|
||||
$("#tags").empty();
|
||||
$.getJSON(url + '/' + riga_id, function(data) {
|
||||
// success data
|
||||
console.log(data[0]);
|
||||
$.getJSON("/admin/service/taglist", {}, function(tags) {
|
||||
$.each(tags, function(i, tag) {
|
||||
$("select[name='mov_fk_tags']").append(
|
||||
new Option(tag.tag_name, tag.id)
|
||||
)
|
||||
$('#tags')
|
||||
.find('option:contains(' + data[0].tag_name + ')')
|
||||
.prop('selected', true)
|
||||
.trigger('change');
|
||||
});
|
||||
});
|
||||
$.getJSON("/admin/service/catlist", {}, function(cats) {
|
||||
$.each(cats, function(i, cat) {
|
||||
$("select[name='mov_fk_categoria']").append(
|
||||
new Option(cat.cat_name, cat.id)
|
||||
)
|
||||
$('#categoria')
|
||||
.find('option:contains(' + data[0].cat_name + ')')
|
||||
.prop('selected', true)
|
||||
.trigger('change');
|
||||
}
|
||||
);
|
||||
});
|
||||
$.getJSON("/admin/service/contolist", {}, function(contis) {
|
||||
$.each(contis, function(i, conto) {
|
||||
$("select[name='conto_id']").append(
|
||||
new Option(conto.nomeConto, conto.id)
|
||||
)
|
||||
$('#conto_id')
|
||||
.find('option:contains(' + data[0].nomeConto + ')')
|
||||
.prop('selected', true)
|
||||
.trigger('change');
|
||||
}
|
||||
);
|
||||
});
|
||||
$('.modal-title').text('Modifica movimento');
|
||||
$('#data').val(data[0].mov_data);
|
||||
$('#descrizione').val(data[0].mov_descrizione);
|
||||
$('#importo').val(data[0].mov_importo);
|
||||
|
||||
$('#myModal').modal('show');
|
||||
// $('.panel-heading').text('Modifica movimento');
|
||||
$('#form').attr('action', '/admin/movimenti/modify');
|
||||
$('#form').append('<input type="hidden" name="id" value="' + riga_id + '">');
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
/*
|
||||
|
||||
$.getJSON("/admin/service/taglist", {}, function(data) {
|
||||
$.each(data, function(i, item) {
|
||||
$("select[name='mov_fk_tags']").append(
|
||||
new Option(item.tag_name, item.id)
|
||||
)
|
||||
});
|
||||
});
|
||||
|
||||
*/
|
||||
|
@ -1,27 +0,0 @@
|
||||
@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
|
@ -1,29 +0,0 @@
|
||||
@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,26 +32,21 @@
|
||||
<tr>
|
||||
<th>Data</th>
|
||||
<th>Categoria</th>
|
||||
<th>Conto Dare</th>
|
||||
<th>Conto Avere</th>
|
||||
<th>Conto</th>
|
||||
<th>Descrizione</th>
|
||||
<th>Importo Dare</th>
|
||||
<th>Importo Avere</th>
|
||||
<th>Importo</th>
|
||||
<th>Azione</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach( $movimenti as $movimento )
|
||||
<tr>
|
||||
|
||||
<td>{{ $movimento->mov_data}}</td>
|
||||
<td>{{ $movimento->Categorie->cat_name ?? ''}}</td>
|
||||
<!-- Uso l'operatore di coalescenza nulla per evitare errori se il conto non esiste -->
|
||||
<td>{{ $movimento->ContoDa->nomeConto ?? '' }}</td>
|
||||
<td>{{ $movimento->ContoA->nomeConto ?? '' }}</td>
|
||||
<!-- Uso l'operatore di coalescenza nulla per evitare errori se il tag non esiste -->
|
||||
<td>{{ $movimento->cat_name }}</td>
|
||||
<td>{{ $movimento->nomeConto }}</td>
|
||||
<td>{{ $movimento->mov_descrizione }}</td>
|
||||
<td>{{ $movimento->mov_importo_dare ." €"}}</td>
|
||||
<td>{{ $movimento->mov_importo_avere." €"}}</td>
|
||||
<td>€ {{ $movimento->mov_importo }}</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>
|
||||
@ -74,8 +69,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- MODAL NEW -->
|
||||
<div class="modal fade " id="myModal" tabindex="-1" role="dialog"
|
||||
aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
@ -115,10 +108,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_dare" aria-describedby="importo">
|
||||
name="mov_importo" aria-describedby="importo">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-7">
|
||||
|
@ -1,53 +0,0 @@
|
||||
@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
|
||||
<option value="nuovo">Crea nuova categoria</option>
|
||||
</select>
|
||||
<input type="text" name="nuovo_valore" id="nuovo_valore" class="form-control mt-2" placeholder="Nome nuova categoria" style="display:none;">
|
||||
<button type="button" class="btn btn-primary mt-2" id="nuovo_aggiungi" style="display:none;">Crea Categoria</button>
|
||||
<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
|
||||
|
||||
@section('js')
|
||||
<script src="/js/app/import_rules.js"></script>
|
||||
@endsection')
|
@ -1,65 +0,0 @@
|
||||
@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" id="importRulesTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Pattern</th>
|
||||
<th>Descrizione</th>
|
||||
<th>Categoria</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>{{ \App\Models\Categorie::find($rule->category_id)->cat_name ?? 'N/A' }}</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
|
||||
|
||||
@section('js')
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#importRulesTable').DataTable({
|
||||
responsive: true,
|
||||
|
||||
order: [[0, "desc"]]
|
||||
});
|
||||
// $('.select2').select2();
|
||||
});
|
||||
</script>
|
||||
@endsection')
|
@ -26,7 +26,6 @@ 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
|
||||
@ -95,26 +94,12 @@ 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::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::get('/admin/movimenti/giroconto', [MovimentiController::class,'giroconto'])->name('giroconto');
|
||||
Route::post('/admin/movimenti/giroconto', [MovimentiController::class,'girocontoPost']);
|
||||
|
||||
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']);
|
||||
@ -277,6 +262,5 @@ Route::middleware('auth:sanctum')->group(function () {
|
||||
Route::delete('/api/conti/{id}', [ApiContoController::class, 'deleteConto']);
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user