Aggiunto la possibilità nelle regole di importazione di poter aggiungere una nuova categoria
This commit is contained in:
parent
637763fafe
commit
750e56f0e9
@ -95,6 +95,9 @@ public function ContoA()
|
|||||||
'mov_fk_tags'=>$request->mov_fk_tags,
|
'mov_fk_tags'=>$request->mov_fk_tags,
|
||||||
'mov_inserito_da'=>$request->userid,
|
'mov_inserito_da'=>$request->userid,
|
||||||
'conto_id'=>$request->conto_id,
|
'conto_id'=>$request->conto_id,
|
||||||
|
|
||||||
|
// 'conto_id_da'=>$request->conto_id_da,
|
||||||
|
// 'conto_id_a'=>$request->conto_id_a,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,21 +220,24 @@ public function ContoA()
|
|||||||
|
|
||||||
public static function listByCategory($cat) {
|
public static function listByCategory($cat) {
|
||||||
|
|
||||||
$expression=DB::raw(' SELECT a.id,
|
// $expression=DB::raw(' SELECT a.id,
|
||||||
a.mov_data,
|
// a.mov_data,
|
||||||
a.mov_importo_dare,
|
// a.mov_importo_dare,
|
||||||
a.mov_importo_avere,
|
// a.mov_importo_avere,
|
||||||
a.mov_descrizione,
|
// a.mov_descrizione,
|
||||||
c.cat_name,
|
// c.cat_name,
|
||||||
t.tag_name,
|
// t.tag_name,
|
||||||
(SELECT Count(entity_id) as quanti FROM gen_docs WHERE entity=0 AND entity_id = a.id) as quanti
|
// (SELECT Count(entity_id) as quanti FROM gen_docs WHERE entity=0 AND entity_id = a.id) as quanti
|
||||||
FROM movimentis as a
|
// FROM movimentis as a
|
||||||
JOIN tags as t ON a.mov_fk_tags=t.id
|
// JOIN tags as t ON a.mov_fk_tags=t.id
|
||||||
JOIN categories as c ON a.mov_fk_categoria=c.id
|
// JOIN categories as c ON a.mov_fk_categoria=c.id
|
||||||
WHERE a.mov_fk_categoria = '.$cat );
|
// WHERE a.mov_fk_categoria = '.$cat );
|
||||||
|
|
||||||
$query = $expression->getValue(DB::connection()->getQueryGrammar());
|
// $query = $expression->getValue(DB::connection()->getQueryGrammar());
|
||||||
return DB::select($query);
|
// return DB::select($query);
|
||||||
|
return self::with(['Tags', 'Categorie'])
|
||||||
|
->where('mov_fk_categoria', $cat)
|
||||||
|
->get();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
31
public/js/app/import_rules.js
Normal file
31
public/js/app/import_rules.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
$(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.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
@ -26,7 +26,10 @@
|
|||||||
@foreach($categorie as $category)
|
@foreach($categorie as $category)
|
||||||
<option value="{{ $category->id }}">{{ $category->cat_name }}</option>
|
<option value="{{ $category->id }}">{{ $category->cat_name }}</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
<option value="nuovo">Crea nuova categoria</option>
|
||||||
</select>
|
</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">
|
<div class="form-group">
|
||||||
<label for="description">Descrizione</label>
|
<label for="description">Descrizione</label>
|
||||||
<textarea name="description" id="description" class="form-control" rows="3" required></textarea>
|
<textarea name="description" id="description" class="form-control" rows="3" required></textarea>
|
||||||
@ -44,3 +47,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
|
@section('js')
|
||||||
|
<script src="/js/app/import_rules.js"></script>
|
||||||
|
@endsection')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user